发现一个ssh-copy-id命令很容易实现
[root@localhost .ssh]# ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
bf:2c:2a:5a:8c:4d:d1:3c:b4:b8:74:27:ca:0c:20:25 root@localhost
[root@localhost ~]# ssh-copy-id -i .ssh/id_rsa.pub root@10.10.31.16
15
root@10.10.31.16's password:
Now try logging into the machine, with "ssh 'root@10.10.31.16'", and check in:
.ssh/authorized_keys
to make sure we haven't added extra keys that you weren't expecting.
使用ssh-agent + keychain:
1. ssh-agent代理
eval `ssh-agent` # 两个反引号
2. 添加ssh-add
ssh-add
Enter passphrase for /home/linux/.ssh/id_dsa: #(输入密码)
3、yum install keychain
4、$ vim $HOME/.ssh/config
StrictHostKeyChecking no
5、cat > .bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
export PSSH_OPTIONS="StrictHostKeyChecking=no"
eval `keychain --eval --agents ssh id_rsa`
阅读(1985) | 评论(0) | 转发(0) |