Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. 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 have done a little googling and have not come up with a clear answer to this question. I was wondering if someone could help me out with this issue.

Is there a way to auto accept any RSA key inside a bash script with no user interference? I need this script to run without user intervention and it will stop every time it encounters a new ip, i just need it to accept all of them.

share|improve this question

migrated from stackoverflow.com Dec 7 '11 at 17:43

This question came from our site for professional and enthusiast programmers.

What command is being run in the bash script? You may want to look at twinpipe or expect. bisqwit.iki.fi/source/twinpipe.html linux.die.net/man/1/expect – Erik Nedwidek May 11 '11 at 19:27
up vote 13 down vote accepted

If all you need is to accept new unknown hosts, try this:

 ssh -o StrictHostKeyChecking=no

If you also need to accept changed host keys, you can trick SSH into using a blank file for storing it's local set of known host keys, then accepting new unknown ones. Note this is a Bad Idea™:

ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no
share|improve this answer
Worked great, thanks. – prolink007 May 11 '11 at 20:39

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.