Skip to content

Commit a2f06e9

Browse files
committed
adding basic key generation script
1 parent 42d10f7 commit a2f06e9

3 files changed

Lines changed: 51 additions & 0 deletions

File tree

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,16 @@ It is also possible to run multiple copies of this container with different port
185185
You can volume map your own text file to `/etc/motd` to override the message displayed upon connection.
186186
You can optionally set the docker argument `hostname`
187187

188+
## Key Generation
189+
190+
This container has a helper script to generate an ssh private/public key. In order to generate a key please run:
191+
```
192+
docker run --rm -it --entrypoint /keygen.sh linuxserver/openssh-server
193+
```
194+
195+
Then simply follow the prompts.
196+
The keys generated by this script are only displayed on your console output, so make sure to save them somewhere after generation.
197+
188198

189199

190200
## Support Info
@@ -251,6 +261,7 @@ Once registered you can define the dockerfile to use with `-f Dockerfile.aarch64
251261

252262
## Versions
253263

264+
* **18.01.20:** - Add key generation script.
254265
* **13.01.20:** - Add openssh-sftp-server.
255266
* **19.12.19:** - Rebasing to alpine 3.11.
256267
* **17.10.19:** - Initial Release.

readme-vars.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,20 @@ app_setup_block: |
7777
You can volume map your own text file to `/etc/motd` to override the message displayed upon connection.
7878
You can optionally set the docker argument `hostname`
7979
80+
## Key Generation
81+
82+
This container has a helper script to generate an ssh private/public key. In order to generate a key please run:
83+
```
84+
docker run --rm -it --entrypoint /keygen.sh linuxserver/openssh-server
85+
```
86+
87+
Then simply follow the prompts.
88+
The keys generated by this script are only displayed on your console output, so make sure to save them somewhere after generation.
89+
8090
8191
# changelog
8292
changelogs:
93+
- { date: "18.01.20:", desc: "Add key generation script." }
8394
- { date: "13.01.20:", desc: "Add openssh-sftp-server." }
8495
- { date: "19.12.19:", desc: "Rebasing to alpine 3.11." }
8596
- { date: "17.10.19:", desc: "Initial Release." }

root/keygen.sh

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#! /bin/bash
2+
3+
# selection menu
4+
echo "Please select your key type to generate"
5+
printf "1.) ecdsa\n2.) rsa\n3.) ed25519\n4.) dsa\n[default ecdsa]:"
6+
read opt
7+
case $opt in
8+
"ecdsa"|1) TYPE="ecdsa" BITS="-b 521";;
9+
"rsa"|2) TYPE="rsa";;
10+
"ed25519"|3) TYPE="ed25519";;
11+
"dsa"|4) TYPE="dsa";;
12+
*) echo "blank or unkown option choosing ecdsa" && TYPE="ecdsa" BITS="-b 521";;
13+
esac
14+
# rsa bit selection
15+
if [[ "$TYPE" == "rsa" ]]; then
16+
echo "Please select RSA bits"
17+
printf "1.) 4096\n2.) 2048\n3.) 1024\n[default 4096]:"
18+
read opt
19+
case $opt in
20+
4096|1) BITS="-b 4096";;
21+
2048|2) BITS="-b 2048";;
22+
1024|3) BITS="-b 1024";;
23+
*) echo "blank or unkown option choosing 4096" && BITS="-b 4096";;
24+
esac
25+
fi
26+
27+
# key generation
28+
echo "YOUR KEY/PUBFILE IS BELOW PLEASE SAVE THIS DATA AS WE WILL NOT"
29+
echo /tmp/stderr{,.pub} | xargs -n 1 ln -sf /dev/stderr && yes | ssh-keygen -t ${TYPE} ${BITS} -N '' -qf /tmp/stderr > /dev/null

0 commit comments

Comments
 (0)