[Unix] The fastest way to log into another machine using ssh

Writing passwords every time you log into another Unix machine using ssh disturbs you?
It could be much simpler:

[[email protected]:~]$ ssh another-machine
Linux 2.6.32.11.
Things will be bright in P.M.  A cop will shine a light in your face.
[email protected]:~$

Solution:
Home:
1. Add to /etc/hosts (as root):

123.124.125.136 another-machine

2. Add to ~/.ssh/config (as user):

Host another-machine
User codesmuggler

3. Generate keys (as user):

ssh-keygen -t rsa

4. Copy id_rsa.pub (public key – very important!) to another-machine.
Another-machine:
5. Add public key to authorized_keys:

cat id_rsa.pub >> ~/.ssh/authorized_keys
rm id_rsa.pub

Its everything! You can log into another-machine using ssh without need of telling password and using only two words:

ssh another-machine
This entry was posted in operating systems, snippets, unix and tagged , , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*


*

You may use these HTML tags and attributes: