Showing posts with label remote access. Show all posts
Showing posts with label remote access. Show all posts

Sunday, January 20, 2008

Using ssh, scp, sftp without password

SSH is a remote access protocol that designed for security purpose, replacing non-secured Telnet. As it main strong point is its security, there's both side signature and authentication to establish a connection. And also, if you notice, most SSH clients didnt offer a "remember password" option and always been asked for password each time you want to connect.

But on linux you can set the connection establish itself without prompting for password. This quite useful if you very often connect to a server. I assuming connecting from LOCAL to SERVER.

1. Log on to LOCAL computer. Run following command :
$ ssh-keygen -t dsa
Left the field empty (press enter to accept the value)
As this step complete, there are 2 file created in your home ~/.ssh/ folder
id_dsa.pub --> this is your public key
id_dsa --> this is your private key

2. Merge the public key into SERVER's authorized key. First we need to transfer the file first using SCP. Add -P option if your SERVER user other port than default SSH port 22.
$ scp ~/.ssh/id_dsa.pub user@SERVER:/tmp
Then, log on to SERVER for further step by
$ ssh user@SERVER -p port_number
Change the port number to a value of your SSH port. If you dont know you may try 22.

3. As we logged on SERVER, merge the public key into authorized_key2 :
$ cat /tmp/id_dsa.pub >> ~/.ssh/authorized_key2
Now you can delete the public key :
$ rm /tmp/id_dsa.pub

4. Now you can SSH, SFTP or SCP to SERVER from LOCAL computer without get prompted by password.

For security reason, please apply this for trusted computer only.