实现思路: A主机生成公钥和私钥,把公钥传输到被远程的服务器B,A通过ssh连接B时,会发送私钥和B主机上的公钥匹配,如果匹配成功则成功连接,反向认证则实现双击认证。 A:192.168.1.154 B:192.168.1.156 A: #ssh-keygen -t dsa -N ‘‘ #ll /root/.ssh/ total 12 -rw-------. 1 root root 668 Jun 23 14:13 id_dsa -rw-r--r--. 1 root root 612 Jun 23 14:13 id_dsa.pub -rw-r--r--. 1 root root 395 Jun 23 14:19 known_hosts #ssh-copy-id -i /root/.ssh/id_dsa.pub root@192.168.1.156 Now try logging into the machine, with "ssh ‘root@192.168.1.154‘", and check in: .ssh/authorized_keys to make sure we haven‘t added extra keys that you weren‘t expecting. #ssh 192.168.1.156 Last login: Sat Jun 21 02:46:23 2014 from 192.168.1.154 这样B就信任A登录,反之则A信任B。
本文出自 “技术小菜” 博客,请务必保留此出处http://390892467.blog.51cto.com/2006821/1429922
原文地址:http://390892467.blog.51cto.com/2006821/1429922