9

I'm trying to run the command ssh -o StrictHostKeyChecking=no but I'm a bit lost as to how to run it. I've tried running it from a shell script, but the output was the man page or settings that lists out all the parameters.

I then tried running that command from the shell (Cygwin) itself, but got the same man output. How do I run the command? Do I need to provide credentials or anything?

6
  • From which OS, other than Cygwin/Windows, did you try it? Commented Sep 11, 2015 at 18:37
  • I tried it on an AWS EC2 instance and got the same result. I don't have command line access to it though; the instance is spun up via datapipeline Commented Sep 11, 2015 at 18:39
  • Did you specify the target hostname? It’s a mandatory argument of the command. How does the full command line look? Commented Sep 11, 2015 at 18:43
  • what are you trying to do? Commented Sep 11, 2015 at 18:53
  • The full command line looks just like that command from the initial post. @Jakuje what I'm trying to do is edit the settings so that an sftp connection automatically accepts keys. On first login from a new computer, I get prompted to accept the key, but need this automated Commented Sep 11, 2015 at 19:46

1 Answer 1

14

Taken from my answer on Ask Different:

You can simply try it as it is without confitguration, just on commandline:

sftp -o StrictHostKeyChecking=no hostname

but I don't think it does all what you need. If you want to ignore all hostkey checking, you need to set up you known_hosts file to /dev/null so there will be never anything stored:

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

or in /etc/ssh_config:

Host hostname
    StrictHostKeyChecking no
    UserKnownHostsFile /dev/null

for specific hostname or you can use * for all host names

5
  • 1
    You may need to edit and remove a few backticks ` Commented Sep 11, 2015 at 20:13
  • I'm still getting the man results when I try this: sftp -o StrictHostKeyChecking=no sftp.host.me -i key.pem [email protected] Commented Sep 11, 2015 at 21:17
  • read on ;) There is more written in the answer. Commented Sep 11, 2015 at 21:26
  • Same thing. I figured it would be easier to point out that the first suggestion wasn't working Commented Sep 11, 2015 at 21:30
  • FYI to fellow Googlers, you might need the -oHostKeyAlgorithms flag instead, which is why this solution is not working for you. Check this: unix.stackexchange.com/questions/699192/… Commented Feb 12, 2023 at 16:24

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.