Generate SSH Keys with Docker

2021-05-08 / Linux Docker

An easy and clean way to generate ssh keys with docker.

1. Create a Folder to Store SSH Key

# ismdeep @ NSA in ~/Desktop [15:08:46]
$ mkdir keys-data

# ismdeep @ NSA in ~/Desktop [15:08:57]
$ cd keys-data

# ismdeep @ NSA in ~/Desktop/keys-data [15:09:00]
$ pwd
/Users/ismdeep/Desktop/keys-data

2. Generate SSH key

docker run --rm \
    -v /Users/ismdeep/Desktop/keys-data:/keys \
    -it ismdeep/ssh-keygen \
    /usr/bin/ssh-keygen -t rsa -C "L. Jiang" -f /keys/ljiang1024 -q -N ""

3. Generate More Secure Keys

docker run --rm \
    -v /Users/ismdeep/Desktop/keys-data:/keys \
    -it ismdeep/ssh-keygen \
    /usr/bin/ssh-keygen -t rsa -b 4096 -C "L. Jiang" -f /keys/ljiang1024 -q -N ""