Example install template: SSH key

Post and discuss VDS templates here. What do you use to preconfigure your own installs?
Post Reply
User avatar
Edge100x
Founder
Founder
Posts: 13180
https://www.youtube.com/channel/UC40BgXanDqOYoVCYFDSTfHA
Joined: Thu Apr 18, 2002 11:04 pm
Location: Seattle
Contact:

Example install template: SSH key

Post by Edge100x »

To kick things off, here is a very basic example install template. It just installs an SSH key, including by modifying the sshd configuration to turn on rsa support if the provided key is rsa (which is a deprecated type but still acceptable).

Template name: Debian 13 (stock) with SSH key
Description: Sets up a normal Debian 13 install, but also installs your provided key to make it easy to log in.
Base OS image: Debian_13_Trixie_x64
Memory needed: 1
Cores minimum: 1
Input #1 label: Your SSH authorized_key entry
Input #1 tooltip: This must be a single line that starts with ssh-rsa, ssh-ecdsa, or ssh-ed25519 (ed25519 is recommended), as output by an OpenSSH or PuTTy key generator. It will be added to /root/.ssh/authorized_keys to allow easy root login. For instance, ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAINIaE1vMrxY9jKRRisaZm44vPIRlSRuw9vuub2SerAPk root@you
Input #1 regex: ^ssh-(ed25519|rsa|ecdsa-sha2-nistp\d\d\d) AAAA(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{4})( [^@\n]+@[^@\n]+)?$

The script:

Code: Select all

#!/bin/bash

INPUT1=${input_1}
mkdir /root/.ssh
echo $INPUT1 > /root/.ssh/authorized_keys
chmod 0700 /root/.ssh
chmod 0600 /root/.ssh/authorized_keys
grep "ssh-rsa" <<< "$INPUT1" && echo "PubkeyAcceptedKeyTypes=+ssh-rsa" >> /etc/ssh/sshd_config
service ssh restart
Post Reply