SSH Key Deployment

by mkorsak
18 deployments · 0 still active · last rev. 1 month 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 7, Debian 8, Ubuntu 16.04 LTS, Ubuntu 16.10, Ubuntu 12.04 LTS, Ubuntu 14.04 LTS
						#!/bin/bash
#
#<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