LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 03-09-2011, 05:20 AM   #1
murmur101
LQ Newbie
 
Registered: Apr 2010
Posts: 15

Rep: Reputation: 1
adding a host to known_hosts non-interactively


Hi,

I have an automated setup (debian) which includes a startup script that rsyncs to a server (always the same server). Everything works well - just that I have to manually confirm that the host is supposed to be added to the known_hosts

Code:
The authenticity of host 'myserver.com (xx.xx.xx.xx)' can't be established.
RSA key fingerprint is 9b:ee:a6:47:hb:92:ac:76:81:94:18:7d:ad:8c:3e:25.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'myserver.com,xx.xx.xx.xx' (RSA) to the list of known hosts.
It is pretty bothersome having to log in to my box just to accept the connection - having the host added automatically (preseed, script) would be nice.

Tried the bold approach editing the ~/.ssh/known-hosts file but without luck as entry seems to be differen for every host. (probably signed)

I would have to fall to "expect" but this is a pretty nasty way to do it. There might be better ways to do it.

Thank you for you creative input...
 
Old 03-09-2011, 05:51 AM   #2
centosboy
Senior Member
 
Registered: May 2009
Location: london
Distribution: centos5
Posts: 1,137

Rep: Reputation: 116Reputation: 116
Quote:
Originally Posted by murmur101 View Post
Hi,

I have an automated setup (debian) which includes a startup script that rsyncs to a server (always the same server). Everything works well - just that I have to manually confirm that the host is supposed to be added to the known_hosts

Code:
The authenticity of host 'myserver.com (xx.xx.xx.xx)' can't be established.
RSA key fingerprint is 9b:ee:a6:47:hb:92:ac:76:81:94:18:7d:ad:8c:3e:25.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'myserver.com,xx.xx.xx.xx' (RSA) to the list of known hosts.
It is pretty bothersome having to log in to my box just to accept the connection - having the host added automatically (preseed, script) would be nice.

Tried the bold approach editing the ~/.ssh/known-hosts file but without luck as entry seems to be differen for every host. (probably signed)

I would have to fall to "expect" but this is a pretty nasty way to do it. There might be better ways to do it.

Thank you for you creative input...


Yes there are...
This is a couple of them

Code:
ssh -o StrictHostKeyChecking=no myserver.com
or

turn off stricthostkeychecking in the global ssh_config file or the local ssh config file. (~/.ssh/config)
 
Old 03-09-2011, 05:56 AM   #3
MCD555
Member
 
Registered: May 2009
Location: Milan, Italy
Distribution: Ubuntu, Debian, Fedora, Oracle Linux
Posts: 109

Rep: Reputation: 10
Quote:
Originally Posted by murmur101 View Post
Hi,

I have an automated setup (debian) which includes a startup script that rsyncs to a server (always the same server). Everything works well - just that I have to manually confirm that the host is supposed to be added to the known_hosts

Code:
The authenticity of host 'myserver.com (xx.xx.xx.xx)' can't be established.
RSA key fingerprint is 9b:ee:a6:47:hb:92:ac:76:81:94:18:7d:ad:8c:3e:25.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'myserver.com,xx.xx.xx.xx' (RSA) to the list of known hosts.
It is pretty bothersome having to log in to my box just to accept the connection - having the host added automatically (preseed, script) would be nice.

Tried the bold approach editing the ~/.ssh/known-hosts file but without luck as entry seems to be differen for every host. (probably signed)

I would have to fall to "expect" but this is a pretty nasty way to do it. There might be better ways to do it.

Thank you for you creative input...
You can get the serer public key (and import it) just using the:

Code:
ssh-keyscan -t rsa,dsa >> ~/.ssh/known-hosts
command when you set up the "new" connection(s).
 
  


Reply


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
SSH host keys are not being read correctly from .ssh/known_hosts. bartonski Linux - Software 3 10-29-2009 05:40 PM
adding host on pvm totaljj Linux - Networking 0 02-13-2007 03:05 PM
cacti adding XP as host noir911 General 1 10-17-2006 07:51 AM
Adding virtual host bestofmed Linux - Networking 2 09-28-2005 05:01 PM
adding host to djbdns dreamz_jaleel Linux - Networking 2 09-20-2004 03:04 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 09:32 PM.

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