Server Fault is a question and answer site for system and network administrators. 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 would like to access my new virtual server in the cloud with ssh from an install script so that it does not ask for user interaction. When I use plain

ssh -i keys.pem

it does tell me that this is a new host, do I trust it? As I freshly create this, I want to trust it without further ado.

Then I did use

-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no

but this does not establish the connection so that later requests go automatically. It does not create the entry in known_hosts.

How can I make ssh to connect non-interactively first and then all the time?

  • Gergely
share|improve this question
up vote 1 down vote accepted

Have you tried just using the following?

$ ssh -o StrictHostKeyChecking=no -i keys.pem

I don't see the point of having -o UserKnownHostsFile=/dev/null as well; this just seems to prevent the addition of the key to your known hosts file.

share|improve this answer
Also, BatchMode=yes would be a good addition. – Janne Pikkarainen Jun 9 '11 at 9:54

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.