Skip to content

Instantly share code, notes, and snippets.

@ollytheninja
Last active May 9, 2022 05:08
Show Gist options
  • Save ollytheninja/e3b0feb0d55633d08692732532d22840 to your computer and use it in GitHub Desktop.
Save ollytheninja/e3b0feb0d55633d08692732532d22840 to your computer and use it in GitHub Desktop.
#!/bin/bash
# First copy your ssh key over
ssh-copy-id pi
# then ssh to the pi
ssh pi
# change the default password
sudo passwd pi
# now run the following to get everything setup
HOSTNAME=newpi
sudo sed -i 's/\(#\)\{0,1\}ChallengeResponseAuthentication .*/ChallengeResponseAuthentication no/g' /etc/ssh/sshd_config
sudo sed -i 's/\(#\)\{0,1\}PasswordAuthentication .*/PasswordAuthentication no/g' /etc/ssh/sshd_config
sudo sed -i 's/\(#\)\{0,1\}UsePAM .*/UsePAM no/g' /etc/ssh/sshd_config
sudo sed -i 's/\(#\)\{0,1\}PermitRootLogin .*/PermitRootLogin no/g' /etc/ssh/sshd_config
sudo sed -i 's/\(#\)\{0,1\}StrictModes .*/StrictModes yes/g' /etc/ssh/sshd_config
sudo sed -i 's/\(#\)\{0,1\}MaxAuthTries .*/MaxAuthTries 6/g' /etc/ssh/sshd_config
sudo sed -i 's/\(#\)\{0,1\}MaxSessions .*/MaxSessions 10/g' /etc/ssh/sshd_config
sudo sed -i "s/raspberrypi/$HOSTNAME/g" /etc/hosts
sudo hostname $HOSTNAME
sudo sh -c "echo $HOSTNAME > /etc/hostname"
sudo apt update
sudo apt upgrade -y
sudo apt install -y git vim
sudo reboot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment