Last active
April 23, 2024 06:11
-
-
Save parente/0227cfbbd8de1ce8ad05 to your computer and use it in GitHub Desktop.
Post-install script to disable SSH password authentication, install latest Docker with AUFS on Ubuntu 14.04 VMs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Disable password authentication | |
sudo grep -q "ChallengeResponseAuthentication" /etc/ssh/sshd_config && sed -i "/^[^#]*ChallengeResponseAuthentication[[:space:]]yes.*/c\ChallengeResponseAuthentication no" /etc/ssh/sshd_config || echo "ChallengeResponseAuthentication no" >> /etc/ssh/sshd_config | |
sudo grep -q "^[^#]*PasswordAuthentication" /etc/ssh/sshd_config && sed -i "/^[^#]*PasswordAuthentication[[:space:]]yes/c\PasswordAuthentication no" /etc/ssh/sshd_config || echo "PasswordAuthentication no" >> /etc/ssh/sshd_config | |
sudo service ssh restart | |
# Install latest Docker | |
sudo apt-get update | |
sudo apt-get -y install linux-image-extra-$(uname -r) | |
sudo sh -c "wget -qO- https://get.docker.io/gpg | apt-key add -" | |
sudo sh -c "echo deb http://get.docker.io/ubuntu docker main\ > /etc/apt/sources.list.d/docker.list" | |
sudo apt-get update | |
sudo apt-get -y install lxc-docker |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
sed -i 's/#PasswordAuthentication.*/PasswordAuthentication no/' /etc/ssh/sshd_config
I just came across this gist, and I think you can shorten that
sed
andecho
into sed in place editing like above. And you probably don't needsudo sh -c
.sudo wget
should do.