If you use Raspberry Pi like a server, you will have more chances to log in with ssh. It is a story that I set up key authentication because it is troublesome to type the password every time.
I think it's the basic method of Linux, so I can find out as many as I can, but I'll leave it here because it's annoying to check it every time.
Create `` `~ / .ssh``` on raspberry pi (only if not already)
$ mkdir ~/.ssh
$ chmod 700 ~/.ssh
Creating authorized_keys
$ touch ~/.ssh/authorized_keys
$ chmod 600 ~/.ssh/authorized_keys
On your own PC (pc on the side that hits the login command)
$ ssh-keygen -t rsa
You will be asked a lot, but for the time being, all are Default (hold down the Enter Key)
Below, the private key and public key are created.
$ ls ~/.ssh
id_rsa id_rsa.pub
id_rsa.Transfer pub to raspberry pi.
Note: If there is a file with the same name on the Raspberry Pi, it makes no sense, and in the worst case it will be overwritten, so it is recommended to rename and transfer it. I used the `` `* .imac``` because it is the key to the imac.
```bash
$ scp id_rsa.pub [email protected]:~/.ssh/id_rsa.pub.imac
Go back to the raspberry pi and work on `` `~ / .ssh```. If the transfer is successful, the files will be placed as shown below.
~/.ssh $ ls
authorized_key id_rsa.pub.imac
id_rsa.pub.The contents of imac are authorized_Register in keys.
```bash
cat id_rsa.pub.imac >> ~/.ssh/authorized_keys
Now you won't be asked for your password the next time you log in with ssh.