Review your favorite Linux distribution.
Go Back > Forums > Linux Forums > Linux - Networking
User Name
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.


  Search this Thread
Old 11-06-2007, 02:22 AM   #1
Registered: Aug 2006
Posts: 34

Rep: Reputation: 15
How to get a non-interactive ssh connection

Hi !

The school in which I happen to study has a network of around 500 computers. Running under Linux (yeheee !).

So I thought I could use this network like a cluster to run heavy computations (like 3D video rendering, etc.), using ssh.

I wrote a script that looks like this (the computers are named on the network a1, a2, ..., b1, b2, ...) to connect to all the computers named a* :
for ((i=0; i<25; i++)); do
    ssh a$i command
The problem was that it always asked my password. So I used ssh-keygen to generate a key that I added to ~/.ssh/authorized_keys, and as my home folder is shared over the network, this solved the problem, I can now connect without typing any password.

Now I still have a problem :
Each time I try to connect to a new computer, ssh looks in ~/.ssh/known_hosts and if the host isn't listed there, it asks :
The authenticity of host 'a1 (' can't be established.
RSA key fingerprint is f7:3f:6c:5c:...:16:c4:64:f4:2e:b6.
Are you sure you want to continue connecting (yes/no)?
Then, if I type "yes", the host is added to known_hosts.
I really wouldn't like to type "yes" 500 times for the first connection on each computer, so the question is :

Is there a way to tell ssh to automatically add the host to known_host and not ask if we're sure we want to connect ?
Or, how can I get from the command-line a host's key, so that I can add it manually to known_hosts ?

Thanks in advance !
Old 11-06-2007, 07:52 PM   #2
Senior Member
Registered: Jan 2005
Location: Nottingham, UK
Distribution: Mageia 5, Linux Lite
Posts: 4,312

Rep: Reputation: 209Reputation: 209Reputation: 209
Check the manpage. In your terminal type: man ssh for a list of usage and options.
Old 11-07-2007, 10:20 AM   #3
Registered: Aug 2006
Posts: 34

Original Poster
Rep: Reputation: 15

Lol thanx for the advice, but I had already spent at least hours googeling & manpaging about ssh before posting, so either it isn't in the manpage, either I skipped it (I'll give the manpage another go, but I don't think I'll find it there).

Hope sombody knows how to do this !
Old 11-09-2007, 11:05 AM   #4
Registered: Feb 2004
Location: Upstate NY
Distribution: Slackware
Posts: 79

Rep: Reputation: 15
heres a link. its for gentoo

but ssh is ssh
Old 11-14-2007, 09:55 AM   #5
Registered: Aug 2006
Posts: 34

Original Poster
Rep: Reputation: 15

Yeeha !
I found how to do it

It's actually really simple :
All you have to do is create a file named ~/.ssh/config, with permissions rw-r--r-- and add ONE SINGLE LINE :

StrictHostKeyChecking no
And if you don't want to change your ~/.ssh/config, you can use :
ssh -o "StrictHostKeyChecking no" host [command]

Last edited by jahvascriptmaniac; 11-18-2007 at 03:20 AM.
Old 11-14-2007, 09:58 AM   #6
Registered: Aug 2006
Posts: 34

Original Poster
Rep: Reputation: 15
P.S. : Please if sombody could set this post as "solved"... I can't find how to do it (and my mous is broken, so it's not as easy to fiddle with things with keyboard only )
Old 11-14-2007, 10:56 AM   #7
Senior Member
Registered: Aug 2003
Location: Berkeley, CA
Distribution: Mac OS X Leopard 10.6.2, Windows 2003 Server/Vista/7/XP/2000/NT/98, Ubuntux64, CentOS4.8/5.4
Posts: 2,986

Rep: Reputation: 45
Thanks for posting the solution. I at least added some tags to your solution so hopefully it will help someone in the future. Certainly helped me!
Old 11-18-2007, 03:19 AM   #8
Registered: Aug 2006
Posts: 34

Original Poster
Rep: Reputation: 15
Oh yes, and if you don't want to change your ~/.ssh/config, you can use :
ssh -o "StrictHostKeyChecking no"
I'll add this to my previous post.



Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
How do you turn off login banner for non-interactive ssh? cpatter12 Linux - Security 21 12-14-2016 02:35 PM
ssh -- Permission denied (publickey,password,keyboard-interactive). davidkline Linux - Networking 11 08-20-2014 02:19 PM
ssh: connection to host port: 22: Connection timed out lost connection cucolin@ Linux - Server 4 11-22-2011 06:15 AM
ssh connection refused - trying to set up ssh server at home openSauce Linux - Server 10 10-18-2007 04:38 PM
non-interactive ssh podollb Linux - Software 3 04-20-2004 03:28 PM > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 08:39 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration