SSH
From Autopilot Wiki
Enabling
- Use
sudo raspi-config
- Interfaces
- SSH
Headlessly
Put an empty file named ssh
in the root "boot" directory of a flashed raspi OS image.
Configuring
By default, configuration is stored in /etc/ssh/sshd_config
Use RSA Key
It's usually bad to be able to login with a password to a network facing computer, especially if your password is two letters like ours tend to be, so we typically want to disable password access over SSH and instead use RSA keys.
- On Target Machine - Enable password login via ssh
- Edit /etc/ssh/sshd_config, make sure the following values are set
ChallengeResponseAuthentication yes PasswordAuthentication yes UsePAM yes
- Restart the ssh service
sudo systemctl restart ssh
- On Source Machine - Generate an RSA key
- check if you have an rsa key generated, they usually live in ~/.ssh
ls -al ~/.ssh
- if you don't have an rsa key generated, generate a key:
ssh-keygen -t rsa
- you'll be prompted where to save the key (if you don't have one just leave it in the default location) and whether to use a passphrase. Having a passphrase means you need to type a password every time you want to use your rsa key. up 2 u. without a passphrase the security model is you assume that no one will be able to access your private key file
- On Source Machine - Install the rsa key
- Use ssh-copy-id
ssh-copy-id <user>@<ip or url>
- If you don't have ssh-copy id...
- On a Mac:
- Install with homebrew. if you don't have homebrew the install command is
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
- then to install ssh-copy id it's
brew install ssh-copy-id
- On Target Machine - Disable password login via ssh
- Edit /etc/ssh/sshd_config, make sure the following values are set
ChallengeResponseAuthentication no PasswordAuthentication no UsePAM yes
- Restart the ssh service
sudo systemctl restart ssh