Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I am usually connecting to the remote server with

ssh user@server.com -p 11000

and then giving the password each time for user. How should I avoid entering the password each time I connect using ssh ?

share|improve this question

3 Answers 3

up vote 11 down vote accepted

I think I should add a bit of a narrative to the link in 9000's answer.

First, check in home to see if you have a folder named .ssh with files inside. If .ssh doesn't exist, you don't have any key set up, so you have to generate a pair using ssh-keygen (it defaults to create the keys in ~/.ssh, you can give the keys a password or not). This will give you a .pub file in ~/.ssh (mine is id_rsa.pub). The file id_rsa.pub should look like:

ssh-rsa lotsofrandomtext user@local

Second, ssh to the server, check to see if you have a file named ~/.ssh/authorized_keys, create it if it doesn't exist. Then, append the contents of the ~/.ssh/id_rsa.pub that you generated earlier in your local machine here. This might mean copying the file contents to your clipboard, then opening ~/.ssh/authorized_keys in a text editor and pasting the lines in.

You should now be able to ssh without typing the password.

Third, if you put this in ~/.ssh/config:

Host server
HostName server.com
Port 11000
User user

You will be able to ssh server (save quite a few key strokes). Thanks to cjm for the User keyword that I forgot to mention.

share|improve this answer
The 'narrative' should also include a discussion of how to avoid typing that pesky passphrase all the time. :-) ssh-agent and/or keychain are possibilities to consider. –  Faheem Mitha Mar 28 '11 at 16:18
Also, if your username on the remote host is not the same as your username on the local host, you can add a User user line to ~/.ssh/config. –  cjm Mar 28 '11 at 17:40
@Faheem That's nice, but I've never set up such thing so I don't think I'm in a position to instruct others about it :) –  phunehehe Mar 29 '11 at 1:35

Turn to key-based authentication.

share|improve this answer
thank you for the suggestion . I had been looking at the forums but was having problem with the port(11000 instead of 22 ). With ssh -P 11000 I was able to copy with ssh . Many thanks. –  Prabesh Shrestha Mar 28 '11 at 15:54

As a supplement to phunehehe's answer, see the Gentoo Linux Keychain Guide for a guide to keychain. keychain also uses ssh-agent. The ssh-agent daemon makes the passphrase available (it becomes unavailable when the ssh-agent daemon dies) but keychain reuses an ssh-agent between logins, and optionally prompts for passphrases each time the user logs in, to quote the guide.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.