Friday, April 5, 2024

ssh keypair raspberry pi

I dont want to use ssh keygen because I already have a pubkey generated previously.
All the other tutorials usually start from there usually,
so heres how you get your pubkey set up on a pi if you've already got one kicking around.

cat ~/.ssh/id_rsa.pub

copy it, login to your pi.

ssh username@raspberrypi.local
mkdir -p ~/.ssh  # Create .ssh directory if not exists
touch ~/.ssh/authorized_keys  # Create authorized_keys file if not exists
vim ~/.ssh/authorized_keys  # Open the authorized_keys file in a text editor

paste it in, change permissions.

chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys

disable password login

you could just use raspi-config but heres how to do it from the term.

sudo vim /etc/ssh/
set PasswordAuthentication no

save and restart ssh service

sudo systemctl restart ssh

No comments:

Post a Comment