I prefer logging in using public key authentication instead of sending the user password each time. How does that work? The local machine generates a pair of keys: whatever is encrypted with one of the key can be decrypted only by the other key. One of the key is sent to the remote server and it's called the public key. So once the server/remote machine has your public key, the local and the server can exchange the actual authentication data in a secure way. Also, the other key, called the private one, gets password-encrypted itself so that somebody snooping onto your hard disk cannot grab it and use it to authenticate to your remote server.

 $ ssh-keygen -t dsa
 Generating public/private dsa key pair.
 Enter file in which to save the key (/home/xxx/.ssh/id_dsa):
 Created directory '/home/xxx/.ssh'.
 Enter passphrase (empty for no passphrase):
 Enter same passphrase again:
 Your identification has been saved in /home/xxx/.ssh/id_dsa.
 Your public key has been saved in /home/xxx/.ssh/
 The key fingerprint is:

Now let's send it securely to the server using scp (secure copy command, part of ssh)

 $ scp .ssh/ root@

Oopsie, I always forget putting the colon at the end! that means scp behaved like cp, making a copy of the file. Let's get rid of it

 $ rm root\@

And now the correct one:

 $ scp .ssh/ root@

the first time an ssh connection is made some more warning will appear

 The authenticity of host '' can't be established.
 RSA key fingerprint is XX:XX:XX:XX:XX:XX.....
 Are you sure you want to continue connecting (yes/no)? yes
 Warning: Permanently added '' (RSA) to the list of known hosts.
 root@'s password: 100% 607 0.6KB/s 00:00

Now I need to add this key to ssh authorized keys list, so let's access the server through ssh to accomplish this

 $ ssh root@
 root@'s password: ...

create .ssh folder if it doesn't exist

 # mkdir .ssh
 # cat >> .ssh/authorized_keys2
 # rm

CTRL-D to exit back to local machine

Now let's try if it works by reconnecting through ssh

 $ ssh root@
 Enter passphrase for key '/[...]/.ssh/id_dsa':

Note that ssh doesn't ask for root password anymore but for the passphrase used to encrypt the private key, instead. If this kind of authentication fails or the user refuses it by pressing CTRL-D, then the old password authentication method is used. This behaviour can be altered by configuring ssh, for details

Ad blocker interference detected!

Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.