我试图从一台远程服务器上将(scp)文件复制到另一台远程服务器上。 远程服务器正在运行Ubuntu并正在使用SSH身份validation。 服务器与LDAP同步,所有用户公钥都存储在LDAP服务器上。
我正在使用OSX Mavericks运行Mac – 我按照这些说明在我的Mac上设置了代理转发: https : //developer.github.com/guides/using-ssh-agent-forwarding/
当我尝试运行命令时:
luca-macbook:~ luca$ scp users@remoteserver:/home/ubuntu/file users@remoteserver:/home/ubuntu/
我得到以下错误:
Host key verification failed. lost connection
有人能告诉我我做错了什么吗?
其次,如果我想复制一个完整的目录,我只是键入相同的上面,它将移动目录中的所有文件,或者我需要有一个-R某处?
提前致谢。
该错误意味着远程主机的密钥已经改变,或者您正在使用StrictHostKeyChecking
:
StrictHostKeyChecking If this flag is set to “yes”, ssh(1) will never automatically add host keys to the ~/.ssh/known_hosts file, and refuses to connect to hosts whose host key has changed. This provides maximum protection against trojan horse attacks, though it can be annoying when the /etc/ssh /ssh_known_hosts file is poorly maintained or when connections to new hosts are frequently made. This option forces the user to manually add all new hosts. If this flag is set to “no”, ssh will automatically add new host keys to the user known hosts files. If this flag is set to “ask”, new host keys will be added to the user known host files only after the user has confirmed that is what they really want to do, and ssh will refuse to connect to hosts whose host key has changed. The host keys of known hosts will be verified automatically in all cases. The argument must be “yes”, “no”, or “ask”. The default is “ask”.
清除它使用:
$ ssh-keygen -R $remoteserver
然后再试一次。 这一次,您应该被要求通过其密钥指纹来确认远程服务器的身份。
要传输整个目录,使用-r
:
-r Recursively copy entire directories. Note that scp follows symbolic links encountered in the tree traversal.
这全部logging在scp(1)
, ssh-keygen(1)
和ssh_config(5)
联机帮助页中。