SSH login with key

If you dont want to login with password everytime or you want to use autossh then you should think about Key Login or Key based authentication in SSH.

Generate SSH-Key:

ssh-keygen

by default they are saved here

/home/pi/.ssh/

 

pi@pi:~/.ssh $ ls -lart
insgesamt 16
drwxr-xr-x 20 pi pi 4096 Jän 3 18:47 ..
-rw-r--r-- 1 pi pi 390 Jän 3 18:47 id_rsa.pub
-rw------- 1 pi pi 1679 Jän 3 18:47 id_rsa
drwx------ 2 pi pi 4096 Jän 3 18:47 .

show content of generated file:

more id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDUs8HxOGrMjM72cf6vv952/qxZ3nOG+BJ9JRCF1JWX6c
JZiHQxce9gz/IZv02G5QL6KbPA5oy5bvNv7LFe25erFLle4rbixiCdKyQ3YjiJquz3R/9oMXYkF/HfJVE
GIYcSgXVF/oRBJbTiSZfG3ryiWgcqPu9zDNHtYHxLcwrzfffYIerDjR86TzXLux9Q+1WUz0MKV6nw5/
I/y9MF7dSo194J2H0qZhlbyf3QYZmC1b94YD7zAz6cayK3iIX1Q/Dra7OqD4v+jdkpkgpiyr1XoKodPo
RPQEYZHgKulwZpl71lqtOv+/oSyW+g+QomvbRXu9PqbXtbRThNQw4YfpiN pi@pi

Copy to remote machine (where you want to login without password)

vi /user/.ssh/authorized_keys

copy the content inside of this file.

SSH Connection to the host should now be possible without using password.

Makes also AutoSSH possible:

autossh -R 20000:localhost:22 root@domain.com

to connect from the other side:

ssh -p 20000 pi@localhost
1+

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert.