Setting Up no-password SSH

Server

Sometime we had a script for running process in remote machine. In this case, we need to setup SSH with no-password to remote another machine and run process what we need.
The basic idea is, however, that in the cryptosystem that ssh uses (RSA or/and DSA) the encription and decription are done using diferent keys
Basically, what the user (client) needs is to generate a public/private key pair. The server will know the public key, but only the client will know the private key.
When the client connects to the server, it tells its own public key. If this key is allowed (if it is between the know public keys list on the server), the server will send a randomic number to the client. This encripted number can only be decripted if the appropiate decription key is used, and this decription key is the client's private one. The client then uses then its own private key and decript the number. If this is done correctly, the server will grant the acces with no more questions. As you can see the system is safe, because the client never tells anybody about its private key; and this key cannot be inferred using the public one.
Now, we must generate a public/private key pair, and copy the public part into the appropiate place on the server side. In this example, we will use user root.

local>ssh-keygen -t dsa
Generating public/private dsa key pair.
Enter file in which to save the key (/root/.ssh/id_dsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_dsa.
Your public key has been saved in /root/.ssh/id_dsa.pub.

A password will be asked, leave this part blank, just pressing <enter>



Now, go the .ssh directory, and you will find two new files: id_dsa and id_dsa.pub. The last one is the public part. Now, copy the public key to the server machine.

local> cd .ssh
local> scp id_dsa.pub user@remote:~/.ssh/id_dsa.pub
user@remote password:
id_dsa.pub 100% 604 0.0KB/s 00:00



Now, add the client's public key to the know public keys on the server

local> ssh user@remote
remote> cd .ssh
remote> cat id_dsa.pub >> authorized_keys2
remote> chmod 640 authorized_keys2
remote> rm id_dsa.pub
remote> exit



That's all. Now we can login use SSH to remote machine without password. But remember, this system will work while none of the machines change the IP address and for the specific user.

 

Reference :

  • Caltech.edu
  • wiki.corebsd.or.id

Comments  

 
0 # 2010-02-09 23:13
Simply use
$ ssh-copy-id -i ~/.ssh/id_rsa.pub


As described here:
alexander.holbreich.org/.../...
Reply | Reply with quote | Quote
 
 
0 # 2011-08-27 19:24
Welcome to the Cialis vs Levitra - the source which can be helpful for you with the choosing ED-medication buy viagra online Cialis Super Active+ Cialis Super Active+ (Tadalafil) has answered our highly raised expectations cheap generic viagra BUY CIALIS ONLINE Without Prescription at $1.45 Per Pill & Get 12 CIALIS Pills FREE ! Brand & Generic Cialis buying viagra Viagra and Levitra is its 17.5-hour half-life (thus Cialis is advertised to viagra samples Find patient medical information for Cialis Oral on WebMD including its uses, side effects viagra samples Cialis - Online Pharmacy! Buy online Cialis - Start buy viagra Why are there so many Cialis commercials on the golf channel ... viagra no prescription HomeOwners for Better Building - Home viagra HomeOwners for Better Building - Home viagra online without prescription Tadalafil - Wikipedia, la enciclopedia libre buy viagra cheap
Reply | Reply with quote | Quote
 
 
0 # 2011-09-01 09:26
Cialis online Ampicillin - Satisfaction And Lowest Prices on ... buy cheap cialis waretownhayride .com cialis 10 mg that gives the pill the shortest activation time, most prolonged time of action and 100% positive result. cialis 10mg s combien ca coute cette taille des levres methode est utilisee dans la couche sous-cutanee. buy cheap cialis Island between 1892 and 1924 Neel cialis for impotence also known as he did healthy, subjects. generic cialis cialis,buy cialis online,cheapest cialis,buy cheap cialis cialis 20mg Home - Baptists Today, The Source for Daily Baptist News for ... cialis 20 mg Bebo provides an open, engaging, and fun environment that empowers a new generation to discover, cialis on line Cialis (tadalafil) increase increases blood flow to a certain area of the body and is cialis online pharmacy Prozac Interaction With Cialis - HealthCentral cheap cialis
Reply | Reply with quote | Quote
 
 
0 # accommuts 2012-01-20 13:12
KOVAL ! why do you only respond to people who threaten to unsubscribe.viagra what about me....Id like a shout out too ....I watched all your videos....TWICE.....i loved you when you weren't? famous.... *sigh*
Reply | Reply with quote | Quote
 

Add comment

Thanks for your comment


Security code
Refresh

About You :

IP Address :
38.107.179.241
United States United States
Browser :
Unknown Unknown
Operating System :
Unknown Unknown

Keep This Site Alive

Your Comment On Tutorial:

Banner
Copyright © 2012 MustNoFee
This blog is 1.485 days since Jan, 12 2008