I have been rebooting raspberry pi a lot lately, and had to SSH into it each time manually and type in password.
There is a simple way to SSH without typing password each time.
1. On laptop 'ls ~/.ssh'
1.1 if above returns id_rsa.pub or id_dsa.pub, key already exists
1.2 if nothing returns or to make new keys 'ssh-keygen -t rsa -C login@devicename' (e.g. ssh-keygen -t rsa -C "kee@myThinkpad0")
1.3 'cat ~/.ssh/id_rsa.pub' returns 'ssh-rsa <RANDOM CHARACTERS> kee@myThinkpad0'
2. Use this command to append public key to Pi, cat ~/.ssh/id_rsa.pub | ssh <USERNAME>@<IP-ADDRESS> 'cat >> .ssh/authorized_keys'
2.1 I typed( cat ~/.ssh/id_rsa.pub | ssh pi@10.42.0.2 'cat >> .ssh/authorized_keys' )
2.2 This command asked for password, and did not succeed.
2.3 Checking whether the file or folder existed on Pi, 'ls ~/.ssh' returned nothing.
2.4 So, created a folder by 'mkdir ~/.ssh' on Pi made 2.1 work.
The source file mentions "Agent admitted failure to sign using the key" error as well as scp method.
I personally prefer scp (scp ./id_rsa.pub pi@10.42.0.2:~/.ssh), however, this might replace previous file which may not be preferred in some cases.
Source: https://www.raspberrypi.org/documentation/remote-access/ssh/passwordless.md
No comments:
Post a Comment