ssh, scp 不输入密码进行操作下载
系统大全为您分享
经常在不同linux机器之间互相scp拷文件,每次总是要输入密码才可行。
通过ssh-keygen生成公钥,在两台机器之间互相建立信任通道即可。
假设本地机器client,远程机器为server。
1. 生成rsa keygen
[winter@client winter] $ ssh-keygen -b 1024 -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/winter/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/winter/.ssh/id_rsa.
Your public key has been saved in /home/winter/.ssh/id_rsa.pub.
The key fingerprint is:
33:d4:7b:9c:87:04:cf:14:40:22:6d:c7:15:78:97:6a winter@client
直接上面公钥和私钥存放地址可以直接回车,私钥密码可以直接回车,知识兔也可以输入。
2. 查看.ssh目录下了多私钥和公钥文件
[winter@client winter] $ ls .ssh/
id_rsa id_rsa.pub known_hosts
3. 拷贝公钥到目标机器上,并改名成authorized_keys
[winter@client winter] $ scp .ssh/id_rsa.pub winter@192.168.0.110:/home/winter/.ssh/authorized_keys
The authenticity of host '192.168.0.110(192.168.0.110)' can't be established.
RSA key fingerprint is 5b:78:e8:e9:dc:d8:db:bd:f7:66:44:e6:3b:ce:f2:79.
Are you sure you want to continue connecting (yes
)? yes
Warning: Permanently added '192.168.0.110' (RSA) to the list of known hosts.
winter@192.168.0.110's password:
id_rsa.pub 100% 221 1.2MB/s 00:00
首次scp命令时候还是会提示输入密码,还有是否继续链接的提示,以后
4. 测试ssh进入
[winter@client winter] $ ssh 192.168.0.110
5. ok,搞定! [winter@server winter] # it's ok!
以上就是系统大全给大家介绍的如何使的方法都有一定的了解了吧,好了,如果知识兔大家还想了解更多的资讯,那就赶紧点击系统大全官网吧。
本文来自系统大全http://www.win7cn.com/如需转载请注明!推荐:win7纯净版
下载仅供下载体验和测试学习,不得商用和正当使用。