主机间无需密码基于ssh通信-创新互联
node1:172.16.58.1
成都网络公司-成都网站建设公司创新互联公司十多年经验成就非凡,专业从事成都网站设计、成都做网站,成都网页设计,成都网页制作,软文营销,1元广告等。十多年来已成功提供全面的成都网站建设方案,打造行业特色的成都网站建设案例,建站热线:18980820575,我们期待您的来电!node2:172.16.58.3
node1--> node2
首先在node1生成秘钥
执行命令ssh-keygen -P '' 询问保存路径直接回车默认即可, 后面提示私钥保存为/root/.ssh/id_rsa 公钥保存为/root/.ssh/id_rsa.pub |
[root@node1 ~]# ssh-keygen -P '' Generating public/private rsa key pair. Enter file in which to save the key (/root/.ssh/id_rsa): 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: dc:62:ba:81:ac:dd:d9:93:fa:b4:9b:21:8d:e7:98:8c root@node1.magedu.com The key's randomart p_w_picpath is: +--[ RSA 2048]----+ | | | | | | | . . | | S . | | . . = . | | o = =. | | o + %o+ | | . E OoBo | +-----------------+ |
把秘钥传给node2主机
ssh-copy-id -i .ssh/id_rsa.pub root@172.16.58.3 |
[root@node1 ~]# ssh-copy-id -i .ssh/id_rsa.pubroot@172.16.58.3 The authenticity of host '172.16.58.3 (172.16.58.3)' can'tbe established. RSA key fingerprint isdb:f8:11:fa:7d:30:95:44:1b:eb:ea:89:ee:fa:a1:27. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added '172.16.58.3' (RSA) to the listof known hosts. root@172.16.58.3's password: Now try logging into the machine, with "ssh'root@172.16.58.3'", and check in: .ssh/authorized_keys to make sure we haven't added extra keys thatyou weren't expecting. |
测试是否成功免密码登陆,没有提示输入密码
ssh 172.16.58.3 'date';date |
[root@node1 ~]# ssh 172.16.58.3 'date';date Wed Dec 31 16:51:41 CST 2014 Wed Dec 31 16:52:42 CST 2014 |
另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。
新闻名称:主机间无需密码基于ssh通信-创新互联
文章URL:http://myzitong.com/article/idihp.html