ssh登录不用口令

ssh登录不用口令

主机192.168.0.2
客户机192.168.0.3
先在客户机上执行以下步骤:
1.#cd /root/.ssh (进入到/root/.ssh/ 目录下)
2.#ssh-keygen -d (产生ssh的公钥和私钥)
Generating public/private dsa key pair.
Enter file in which to save the key (/root/.ssh/id_dsa): (产生到何处.按Enter 就可以了)
Enter passphrase (empty for no passphrase): (要不要设定passwd.避免问我们按Enter 就可以了)
Enter same passphrase again: (再按一次Enter)
Your identification has been saved in /root/.ssh/id_dsa.
Your public key has been saved in /root/.ssh/id_dsa.pub.

此时目录下会产生公钥id_dsa.pub和私钥id_dsa
现在要把id_dsa.pub丢到192.168.0.2 并且更名为 authorized_keys

3.#scp id_dsa.pub 192.168.0.2:/root/.ssh/authorized_keys
[email protected]'s password:
id_dsa.pub 100% |*****************************| 613 00:00

试试看 ssh 到server 应该就不用输入密码了
4.#ssh 192.168.0.2
#exit (记得离开)


疑问:
这样操作后,客户机可以直接连接主机了,连口令都不要了,而当初只是把客户机上的id_dsa.pub拷入主机,这样好象不×××全啊。


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章