Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to SSH to a server on startup with a .sh script, but that will require me to enter the password for the account on the server that I'm SSHing to. I did some RTFMing, and I see in "-o" that it has "PasswordAuthentication" but I'm not sure how or if I could use that option. As this will be in a shell script, obviously I'd like to have the password in that file, or in any case not have to enter in the password manually every time the script runs.

share|improve this question
This still is valid:… :) – Rinzwind Dec 1 '12 at 9:38
Thanks - checking it now :) – Eva Dec 1 '12 at 9:43
How can I make ssh-copy-id use a port other than 22? I tried it with -p but I get: Bad port 'umask 077; test -d ~/.ssh || mkdir ~/.ssh ; cat >> ~/.ssh/authorized_keys' – Eva Dec 1 '12 at 9:55
Create a new question for the TCP-port thing. – jippie Dec 1 '12 at 10:07… – Eva Dec 1 '12 at 10:18
up vote 2 down vote accepted

I'm on my phone now so I can't give you a detailed answer. The proper solution here in my opinion is to use key based authentication. Basically you use ssh-keygen (I think) to generate a public/private key pair. Since you need script access, enter a blank password when prompted. Then, follow the relevant man pages to install the public key on the server and install the private key in its proper place.

Now you should be able to log in to that server securely and without a password. Note that by securely I mean as long as your user account isn't compromised.

share|improve this answer

I would suggest that you use ssh-keygen to generate an ssh key and use that to login to your remote ssh server.

The procedure is explained here.

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.