第一步:ssh的设置
把你的本地主机用户的ssh公匙文件写入到远程主机用户的~/.ssh/authorized_keys文件中,具体方法是假设本地主机为daqi3@10.129.1.1,远程主机daqi2@10.129.1.1
一:先屏蔽scp命令调用时出现的口令提示,在
daqi3@10.129.1.1主机里的用户
运行
ssh-keygen -t rsa 结果如下
Generating public/private rsa key pair.
Enter file in which to save the key (/home/.username/ssh/id_rsa):#回车
Enter passphrase (empty for no passphrase):#回车
Enter same passphrase again:#回车
Your identification has been saved in /home/.username /.ssh/id_rsa.
Your public key has been saved in /home/.username /.ssh/id_rsa.pub.
The key fingerprint is:
38:25:c1:4d:5d:d3:89:bb:46:67:bf:52:af:c3:17:0c username@localhost
Generating RSA keys:
Key generation complete.
会在用户目录~/.ssh/产生两个文件,id_rsa,id_rsa.pub
二:
把id_rsa.pub文件拷贝到
daqi2@10.129.1.1
主机的用户目录下 然后再运行如下命令
在
daqi2@10.129.1.1
目录下,运行cat
id_rsa.pub >~/.ssh/authorized_keys
它将在
daqi2@10.129.1.1
的/.ssh/目录下面生成authorized_keys这个文件
完成以后,在命令提示符下面输入SCP命令测试一下
如:scp /opt/dbback/data/aa.dmp.zip root@10.10.29.1:/opt/dbback/
手工测试的时候,如果不出现提示要输入密码,这说明成功了。