Configuring Passwordless SSH
Passwordless SSH works by pre-sharing public encryption keys. It is important to understand that setting up passwordless SSH opens your servers to certain security risks. A compromised user account on one server may allow the attacker to gain access to multiple systems on the network. Try to avoid using passwordless access for accounts with elevated privileges.
The first step is to take a look at what you have in your ~/.ssh directory. If you do not see files called “id_rsa” and “id_rsa.pub”, then you need to generate them:
ssh-keygen -b 2048 -t rsa
When prompted for a passphrase, leave it blank (just hit “Enter” twice).
Now you need to copy the “id_rsa.pub” to the destination SSH server:
ssh-copy-id -i ~/.ssh/id_rsa.pub username@host
You will need to enter your password to complete this task. After this step you should be able to just type “ssh username@host” and log in without being prompted for password.
If you need to copy the “id_rsa.pub” to a large number of remote hosts, having to enter your password every time can get tiresome. The alternative is to use the expect utility to handle the tedious work. Enter all the hostnames into a file – one per line – called server_list and use the following script:
cat server_list | while read host do expect -c " set timeout 5 spawn ssh-copy-id -i /home/username/.ssh/id_rsa.pub username@${host} expect "ssword:" { send "yourpasswordr" } expect eof" done
It is important to use the explicit path to your “id_rsa.pub” file. Do not use “~” or “$HOME” global variables.
5 Comments »
1 Pingbacks »
-
[…] passwordless SSH from the monitoring host to the monitored client. Instructions are available here. Second, for notification this script uses “mailx”, so you need sendmail configured on […]
I’m on a Mac on Network “A”, and I am trying to get to another computer that is in Network “B”, so I can access my home account. However, Network “B” has 3 computers — a Mac, and 2 PCs. Is there a way that I could use SSH on the Mac on “A” to connect to “B”?
My webhosting company allows me to use SSH for my website. Does this mean I could SSH in the Linux os and launch the files need to run the dedicated server? Or is the SSH limited to just the website root directory?
Internal ssh works fine, but from Internet I can not connect to Cisco or even to computers that connected to cisco
I have my own dedicated server running Linux Cent OS. I need to know the SSH command line to find out the current WordPress version for all my 25 websites hosted on it.
Please help.
Thanks in advance.
I have downloaded ssh program but i do not know how to use it. Must i install this program to the host computer (remote computer that i want to connect it) ? is the host name is the IP address? what is the differences between user name and the host name that are required to connect to the remote computer.What is the port number?