SSH Key Deployment

by mkorsak
26 deployments · 2 still active · last rev. 2 years ago

This script deploys a Linode with your SSH key preinstalled on the root account and SSH password authentication disabled.

Compatible with: CentOS 7, Debian 8, Ubuntu 16.04 LTS, Ubuntu 14.04 LTS
#<UDF name="ssh" label="SSH Public Key:">
# SSH=

# This updates the packages on the system from the distribution repositories.
apt-get update
apt-get upgrade -y

# This sets your public key on your Linode
mkdir ~/.ssh
echo "${SSH}" >> ~/.ssh/authorized_keys

# This disables password authentication
sed -i 's/#*PasswordAuthentication [a-zA-Z]*/PasswordAuthentication no/' /etc/ssh/sshd_config

# This restarts the SSH service, with two commands to cover more distributions
systemctl restart sshd
service ssh restart