实现思路: A主机生成公钥和私钥,把公钥传输到被远程的服务器B,A通过ssh连接B时,会发送私钥和B主机上的公钥匹配,如果匹配成功则成功连接,反向认证则实现双击认证。A:192.168.1.154B:192.168.1.156A:#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.156Now try logging into the machine, with "ssh 'root@192.168.1.154'", and check in: .ssh/authorized_keysto make sure we haven't added extra keys that you weren't expecting.#ssh 192.168.1.156Last login: Sat Jun 21 02:46:23 2014 from 192.168.1.154这样B就信任A登录,反之则A信任B。