Linux下,要想scp自动输入远端服务器的密码来拷贝文件,一般借助expect脚本来达到目的。两台服务器之间互信是指,用scp拷贝文件、ssh登陆、rsync同步文件等操作的时候,不需要输入远端服务器的用户密码就可以完成操作。

以下在SUSE 10.1上,来说明如何建立两台服务器的通信互信机制。使用root用户,192.168.0.170若要无密码ssh登陆192.168.0.147机器:
1.       170上生成认证RSA密钥:
ssh-keygen -b 1024 -t rsa
中间过程直接回车。在/root/.ssh2/目录下,生成了两个文件:
id_rsa_1024_a(私钥文件放在本地) id_rsa_1024_a.pub(公钥文件放在信任服务器)
为了方便管理,将它们重命名:
mv id_rsa_1024_a    root_192.168.0.170
mv id_rsa_1024_a.pub    root_192.168.0.170.pub
2.       170上,在/root/.ssh2/下,私钥验证文件identification中追加(cat >> identification):
IdKey root_192.168.0.170
3.       将公钥文件拷贝到147上:
scp root_192.168.0.170.pub root@192.168.0.147:/root/.ssh2
4.       Root用户登陆147,在/root/.ssh2/下,公钥验证文件authorization中追加(cat >> authorization):
Key root_192.168.0.170.pub
这样147root用户就信任了来自170root用户通信。在170,往147scpsshrsync都是免密码了。
 

 

 


转载本站文章请注明,转载自:神秘果

本文链接: http://www.shenmiguo.com/archives/2009/316_linux-ssh-trust.html

Leave a Reply

You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <font color="" face="" size=""> <span style="">