2013/11/14

Published 11月 14, 2013 by

使用ssh,建立不用帳密認證立即登入主機

1.產生ssh KEY
2.交換ssh key
3.互相登入對方的主機,即可快速登入主機




[root@C5TOFR1 ~]# ssh-keygen -t dsa

Generating public/private dsa key pair.
Enter file in which to save the key (/root/.ssh/id_dsa):
Created directory ‘/root/.ssh’.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_dsa.
Your public key has been saved in /root/.ssh/id_dsa.pub.
The key fingerprint is:
[root@C5TOFR2 ~]# ssh-keygen -t dsa
Generating public/private dsa key pair.
Enter file in which to save the key (/root/.ssh/id_dsa):
Created directory ‘/root/.ssh’.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_dsa.
Your public key has been saved in /root/.ssh/id_dsa.pub.
The key fingerprint is:

Set ssh(二台都要做)

Change Key
[root@C5TOFR2 ~]# scp ~/.ssh/id_dsa.pub root@C5TOFR1l:~/.ssh/authorized_keys
[root@C5TOFR1 ~]# scp ~/.ssh/id_dsa.pub root@C5TOFR2:~/.ssh/authorized_keys