1827452 Members
4714 Online
109965 Solutions
New Discussion

scp

 
K.C. Chan
Trusted Contributor

scp

All, I've setup public and private keys for ssh so that I would NOT need to provide a passphrase when logging in. However, sometime when I do an "scp" and when the server can't authenticate, it ask if it should put the host name into the known_hosts2 file. This annoys me, is there a way to tell it, yes go ahead and do it, don't ask. Thanks.
Reputation of a thousand years can be determined by the conduct of an hour
6 REPLIES 6
Jairo Campana
Trusted Contributor

Re: scp

 
legionx
Jairo Campana
Trusted Contributor

Re: scp

sorry correction:
if host connect A Y B
the know_host of host A contains
hostB,ip and password encryp generated whith ssh-keygen or ssh_host_key and copy and paste the contains of identity.pub

legionx
Darrell Allen
Honored Contributor

Re: scp

Hi Michael,

In my experience, ssh / scp only asks you if you want to add the host to the known hosts until you answer yes. Once it's a known host, ssh will not bother you again for that host.

Darrell
"What, Me Worry?" - Alfred E. Neuman (Mad Magazine)
Mark Fenton
Esteemed Contributor

Re: scp

Michael,

The way around this is to add the hosts to the global know_hosts2 file (specified in ssh.config), and have that file checked first before the user's own files. Thus once root has accepted a particular host, everyone will recognize that host as being ok, and the question won't be asked again.

Hope this helps!

Mark
Michael Chan_3
Occasional Advisor

Re: scp

Hi all, if you know what hosts you will be using, can't you proactively add the host in manaully via some sort of command? what I want to do is
has out /etc/hosts and add them to the known_hosts2 file. Thanks.
Mark Fenton
Esteemed Contributor

Re: scp

In theory that would work -- you just need to know the host's name, IP and public key. (take a look at this excerpt from a known_hosts2 file for an example):
host.somedomain.com,xxx.xxx.xxx.xxx ssh-rsa 5AAAB3NzaC1yc2EAAAABIwAAAIEAosJtIznGMOqLA/TU89f3q+7YbIPg4ohl4TbWuhY9fn5PQMDksZsypf5D9FyqFKIUnSxFMRY8wAI0S6t/h2Ur8aSh/RcPe4MIVAuIs5wad4DSL3Xz7arW1GMJNt3yTOnt8NntSLb/XEjguN1FtdxA2L84l/5M07v4cqcfKFaVUE0=

If you set up the keys for all the hosts yourself, then you should have the host keys available. copy the info in the format listed above into a known_hosts2 file (either one for each user who will be using ssh, or to the system default known_hosts2 file) and it should work.

As to how to automate this -- I suppose if you generated all the keys on one server, you could just copy all the ssh_host_xxx_key.pub (where xxx is either rsa or dsa as appropriate) files into one known_hosts2 file, and then edit to include the hostname and ip.