服装网站源码php,wordpress页面位置,php网站开发小程序,中国建设银行网站保定五四路有些时候#xff0c;我们在复制/移动文件 到另一台机器时会用到scp#xff0c;因为它比较安全。但如果每次都要输入密码#xff0c;就比较烦了#xff0c;尤其是在script里。不过#xff0c;ssh有另一种用密钥对来验证的方式。下面写出我生成密匙对的过程#xff0c;供大…有些时候我们在复制/移动文件 到另一台机器时会用到scp因为它比较安全。但如果每次都要输入密码就比较烦了尤其是在script里。不过ssh有另一种用密钥对来验证的方式。下面写出我生成密匙对的过程供大家参考。第一步生成密匙对我用的是rsa的密钥。使用命令 ssh-keygen -t rsa[user1rh user1]$ ssh-keygen -t rsa Generating public/private rsa key pair. Enter file in which to save the key (/home/user1/.ssh/id_rsa): Created directory /home/user1/.ssh. Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /home/user1/.ssh/id_rsa. Your public key has been saved in /home/user1/.ssh/id_rsa.pub. The key fingerprint is: e0:f0:3b:d3:0a:3d:da:42:01:6a:61:2f:6c:a0:c6:e7 user1rh.test.com [user1rh user1]$复制代码 生成的过程中提示输入密钥对保存位置直接回车接受默认值就行了。接着会提示输入一个不同于你的password的密码直接回车让它空着。当然也可以输入一个。(我比较懒不想每次都要输入密码。) 这样密钥对就生成完了。其中公共密钥保存在 ~/.ssh/id_rsa.pub私有密钥保存在 ~/.ssh/id_rsa然后改一下 .ssh 目录的权限使用命令 chmod 600 ~/.ssh[user1rh user1]$ chmod -R 600 ~/.ssh [user1rh user1]$复制代码 之后把这个密钥对中的公共密钥复制到你要访问的机器上去并保存为 ~/.ssh/authorized_keys.scp ~/.ssh/id_rsa.pub 192.168.11.51:/root/.ssh/authorized_keysuser1rh1s password: id_rsa.pub 100% 228 3.2MB/s 00:00 scp ./newfile root192.168.11.51:/home