$ -weight: 500;">systemctl -weight: 500;">status ssh
-weight: 500;">systemctl -weight: 500;">status ssh
-weight: 500;">systemctl -weight: 500;">status ssh - Enabling the SSH Server on Rasbian OS
- Generating asymmetric encryption key pair: Public Key: Goes onto the Raspberry Pi 5 - think of the public key as the lock which locks down the Raspberry Pi or remote device. Private Key: Stays on the client device - think of the private key as the key to unlock the lock once a device has a lock put on it.
- Public Key: Goes onto the Raspberry Pi 5 - think of the public key as the lock which locks down the Raspberry Pi or remote device.
- Private Key: Stays on the client device - think of the private key as the key to unlock the lock once a device has a lock put on it.
- Copying the public key to the Raspberry Pi 5
- Configuring the SSH configuration file on Raspbian OS Disable Password Authentication Disable X11 Disable Root Login Change the maximum amount of tries to authenticate to the remote device
- Disable Password Authentication
- Disable X11
- Disable Root Login
- Change the maximum amount of tries to authenticate to the remote device - Public Key: Goes onto the Raspberry Pi 5 - think of the public key as the lock which locks down the Raspberry Pi or remote device.
- Private Key: Stays on the client device - think of the private key as the key to unlock the lock once a device has a lock put on it. - Disable Password Authentication
- Disable X11
- Disable Root Login
- Change the maximum amount of tries to authenticate to the remote device - Open terminal (CTRL + CMD (WIN) + T) -or- clicking on the terminal icon.
- Type in -weight: 600;">sudo raspi-config into the terminal. This will open up the Raspberry Pi Software Configuration Tool. We will select Interface Options.
- Select SSH from the menu. The tool will prompt you to confirm whether you want to -weight: 500;">enable SSH Server, select Yes.
- The tool will prompt you to confirm whether you want to -weight: 500;">enable SSH Server, select Yes.
- This should -weight: 500;">enable the SSH Server - The tool will prompt you to confirm whether you want to -weight: 500;">enable SSH Server, select Yes. - Run the command -weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">enable ssh
- Restart SSH for good measure, -weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">restart ssh
- Verify SSH is running, -weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">status ssh - On the client device (the device you will be using to SSH into the Raspberry Pi) type in ssh <username>@<hostname> or ssh <username>@<ip-address>
- If you are able to login, then we can disconnect the peripherals. - Open the terminal.
- Enter in ssh-keygen -t ed25519 -C "<username>@<client-machine/hostname>: ssh-keygen: We are telling our machine to create a pair of keys. A private key which we keep on the client machine A public key which we will share to the remote host (Raspberry Pi 5) -t ed25519: We are telling the command what kind of encryption to use. -C "<username>@<hostname>": This is the label we are going to provide the key. jsmith@macbook-pro for example is what the label would look like.
We want to ensure we create a meaningful label.
- ssh-keygen: We are telling our machine to create a pair of keys. A private key which we keep on the client machine A public key which we will share to the remote host (Raspberry Pi 5)
- A private key which we keep on the client machine
- A public key which we will share to the remote host (Raspberry Pi 5)
- -t ed25519: We are telling the command what kind of encryption to use.
- -C "<username>@<hostname>": This is the label we are going to provide the key. jsmith@macbook-pro for example is what the label would look like.
We want to ensure we create a meaningful label.
- jsmith@macbook-pro for example is what the label would look like.
- We want to ensure we create a meaningful label.
- The program will prompt you for a passphrase and this is essentially the password you will now use to login remotely to this Raspberry Pi when using encryption. The reason we create the passphrase is to ensure we make the private key really secure. This way, even if the private key is compromised (stolen), if they don't know the passphrase, they won't be able to login.
- The reason we create the passphrase is to ensure we make the private key really secure. This way, even if the private key is compromised (stolen), if they don't know the passphrase, they won't be able to login.
- Verify the keys were created: ls -la ~/.ssh. You should see: id_ed25519 which is the private key id_ed25519.pub which is the public key Note: This is if you left the default label, or did not specify a label.
- id_ed25519 which is the private key
- id_ed25519.pub which is the public key
- Note: This is if you left the default label, or did not specify a label. - ssh-keygen: We are telling our machine to create a pair of keys. A private key which we keep on the client machine A public key which we will share to the remote host (Raspberry Pi 5)
- A private key which we keep on the client machine
- A public key which we will share to the remote host (Raspberry Pi 5)
- -t ed25519: We are telling the command what kind of encryption to use.
- -C "<username>@<hostname>": This is the label we are going to provide the key. jsmith@macbook-pro for example is what the label would look like.
We want to ensure we create a meaningful label.
- jsmith@macbook-pro for example is what the label would look like.
- We want to ensure we create a meaningful label. - A private key which we keep on the client machine
- A public key which we will share to the remote host (Raspberry Pi 5) - jsmith@macbook-pro for example is what the label would look like.
- We want to ensure we create a meaningful label. - The reason we create the passphrase is to ensure we make the private key really secure. This way, even if the private key is compromised (stolen), if they don't know the passphrase, they won't be able to login. - id_ed25519 which is the private key
- id_ed25519.pub which is the public key
- Note: This is if you left the default label, or did not specify a label. - Open up terminal if it's not up already.
- Enter in ssh-copy-id username@server-hostname or ssh-copy-id username@host-ip You are copying this to whatever username and hostname you created for your Raspberry Pi 5, or remote client (if you are doing this on another device).
- You are copying this to whatever username and hostname you created for your Raspberry Pi 5, or remote client (if you are doing this on another device).
- Verify Key-based Authentication Works - ssh username@hostname It will ask for your passphrase - this means that key-based authentication works. It should log you into the remote client.
- It will ask for your passphrase - this means that key-based authentication works.
- It should log you into the remote client. - You are copying this to whatever username and hostname you created for your Raspberry Pi 5, or remote client (if you are doing this on another device). - It will ask for your passphrase - this means that key-based authentication works.
- It should log you into the remote client. - PermitRootlogin: We want to ensure we prevent direct SSH Login as root. Value: no Root can do anything, so we want to ensure we -weight: 500;">disable this and use -weight: 600;">sudo when we need to do something. Disabling Root Login reduces an attack surface.
- Root can do anything, so we want to ensure we -weight: 500;">disable this and use -weight: 600;">sudo when we need to do something.
- Disabling Root Login reduces an attack surface.
- PasswordAuthentication: We want to ensure we use keys only. Value: no Since we have keys, we don't need to SSH in with our password. Disabling Password Authentication reduces an attack surface.
- Since we have keys, we don't need to SSH in with our password.
- Disabling Password Authentication reduces an attack surface.
- X11Forwarding: We don't need to see the GUI for applications, since we will be using the command-line. You can leave this enabled if you need GUI access to the machine. Value: no Reduces an attack surface.
- Reduces an attack surface.
- MaxAuthTries: We want to limit this from 6 to 3. Value: 3 This is minor security hygiene but we don't want to give an attacker a lot of tries. Reduces an attack surface.
- This is minor security hygiene but we don't want to give an attacker a lot of tries.
- Reduces an attack surface. - Root can do anything, so we want to ensure we -weight: 500;">disable this and use -weight: 600;">sudo when we need to do something.
- Disabling Root Login reduces an attack surface. - Since we have keys, we don't need to SSH in with our password.
- Disabling Password Authentication reduces an attack surface. - Reduces an attack surface. - This is minor security hygiene but we don't want to give an attacker a lot of tries.
- Reduces an attack surface. - Open the terminal.
- Go to /etc/ssh
- Use nano to open sshd_config: -weight: 600;">sudo nano sshd_config
- Find the above settings, and set the values to the specified value.
- Use crtl-o and then ctrl-x in nano to close the file. - Back up your private key to an encrypted USB drive or a password manager that supports file attachments
- Generate keys from multiple devices and add all public keys to authorized_keys — it supports multiple entries
- Physical access is your safety net — this is a major advantage of a homelab over a cloud VPS - OpenSSH Manual — sshd_config
- Mozilla SSH Guidelines