You have two connected computers and want to log in to one computer from the other without entering your password every time.
Check the following entries:
Two computers, equipped with working network cards and properly connected.
The package openssh
is installed on both computers.
The SSH port on both computers is open. You have to check your firewall settings.
The SSH daemon runs on each computer.
We assume that there are two computers with the following parameters:
Name | IP Address | |
---|---|---|
Computer A | earth | 192.178.1.1 |
Computer B | moon | 192.178.1.2 |
Do the following:
Create your public and private key pair on
earth
first:
Create the key pair with
ssh-keygen -t rsa
Enter the file in which to save the key. In general, you can use the default value and just hit Enter.
Do not enter a passphrase.
If you have the same login name on both computers, copy your
public key to moon
with:
ssh-copy-id -i ~/.ssh/id_rsa.pub moon
If you need to work on moon
with a
different user, use this:
ssh-copy-id -i ~/.ssh/id_rsa.pub user_on_moon@moon
If you do not have ssh-copy-id, use the following procedure:
Export your public key to moon
:
cat ~/.ssh/id_rsa.pub | ssh moon 'cat >> .ssh/authorized_keys'
Enter the password on moon
.
Log in to moon
and set the
correct permissions:
chmod 644 ~/.ssh/authorized_keys
Log in to moon
with ssh
moon
. If need a different user, use
ssh user_on_moon@moon
.
After these steps, you can log in from
earth
to moon
without entering a password. If you also want to log in the other way
around, just exchange the two names and repeat the above steps.
If something does not work, check the following:
Are the two computers connected properly?
Can you ping earth
from
moon
and vice versa? Use
ping earth
or ping 192.178.1.1.
This is the main Web page for SSH.
ssh
Find more information about the command ssh in this man page.