January 23, 2016

ssh login without password via id_rsa

machine A - client
machine B - server

on A run
ssh-keygen -t rsa
if asked to provide password just press ENTER

Result:
ls ~/.ssh

you should see the id_rsa & id_rsa.pub files


login via ssh to B

ssh username@machine_ip
promt for password - type in your password

ls ~/.ssh

if directory does not exist - create it
mkdir ~/.ssh

if directory exists - log out

on A

let's copy the id_rsa.pub key to remote server B

cat .ssh/id_rsa.pub | ssh username@machine_b_ip  'cat >> .ssh/authorized_keys'
promt for password - type in your password


we are almost done. From now you can login to remote machine without password promt. But we need to take some security providing steps.

from A let's login to B

ssh username@machine_b_ip

No password promt. You have been loged in to remote server 2.
Please apply

chmod go-w ~/
chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys

No comments:

Post a Comment

How to type letters with accent

Very useful article https://www.freecodecamp.org/news/how-to-type-letters-with-accents-on-mac/