快速业务通道

设置Linux系统的固定IP地址

作者 佚名技术 来源 Linux系统 浏览 发布时间 2012-04-08

其实今天突然想到要配置SSH等价性是,项目有个小小小小需求,想做到每天同步两边的TDI脚本文件,

但是又不能把root密码写成明文,今天突然想到,可以配置SSH 等价性,使用scp,写成shell脚本,放到crontab里就好了 .

以下为实验环境的配置详情


rhel4-sec主机
[root@rhel4-sec ~]# pwd
/root
[root@rhel4-sec ~]# mkdir .ssh
[root@rhel4-sec ~]# chmod 700 .ssh/
[root@rhel4-sec ~]# cd .ssh/
[root@rhel4-sec .ssh]# ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
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:
de:15:ee:84:2c:dd:60:9c:39:cd:41:a2:e9:b4:e6:2a root@rhel4-sec
[root@rhel4-sec .ssh]# ssh-keygen -t dsa
Generating public/private dsa key pair.
Enter file in which to save the key (/root/.ssh/id_dsa): 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:
6b:cb:c8:34:56:9e:0b:e5:06:4d:4b:c1:dc:b8:64:36 root@rhel4-sec
[root@rhel4-sec .ssh]# cat *.pub > authorized_keys
[root@rhel4-sec .ssh]# scp authorized_keys rhel5-2:/root/

rhel5-2 主机
[root@rhel5-2 ~]# pwd
/root
[root@rhel5-2 ~]# mkdir .ssh
[root@rhel5-2 ~]# chmod 700 .ssh/
[root@rhel5-2 ~]# cd .ssh/
[root@rhel5-2 .ssh]# ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
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:
c1:08:5e:0d:43:ad:e1:87:58:5e:0d:14:26:c5:4b:b7 root@rhel5-2
[root@rhel5-2 .ssh]# ssh-keygen -t dsa
Generating public/private dsa key pair.
Enter file in which to save the key (/root/.ssh/id_dsa):
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:
2f:de:ed:6f:48:b5:72:7e:93:91:c7:b3:2e:14:5a:e3 root@rhel5-2

[root@rhel5-2 .ssh]# cp /root/authorized_keys /root/.ssh/
[root@rhel5-2 .ssh]# cat *.pub >> authorized_keys
[root@rhel5-2 .ssh]# scp authorized_keys rhel4-sec:/root/.ssh/

成功之后的效果
在rhel5-2 上直接ssh到rhel4-sec,不需要输入密码
[root@rhel5-2 ~]# ssh rhel4-sec
Last login: Thu Sep 16 12:55:52 2010 from rhel5-2
[root@rhel4-sec ~]# id
uid=0(root) gid=0(root) groups=0(root),1(bin),2(daemon),3(sys),4(adm),6(disk),10(wheel),500(idsldap),512(ivmgr),513(tivoli)

在rhel4-sec上直接 ssh到rhel5-2,一样不需要输入密码
[root@rhel4-sec .ssh]# ssh rhel5-2
Last login: Thu Sep 16 13:02:14 2010 from 10.1.1.1
[root@rhel5-2 ~]# id
uid=0(root) gid=0(root) groups=0(root),1(bin),2

凌众科技专业提供服务器租用、服务器托管、企业邮局、虚拟主机等服务,公司网站:http://www.lingzhong.cn 为了给广大客户了解更多的技术信息,本技术文章收集来源于网络,凌众科技尊重文章作者的版权,如果有涉及你的版权有必要删除你的文章,请和我们联系。以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!

分享到: 更多
上一篇: paper下一篇: 配置linux SSH 等价性

Copyright ©1999-2011 厦门凌众科技有限公司 厦门优通互联科技开发有限公司 All rights reserved

地址(ADD):厦门软件园二期望海路63号701E(东南融通旁) 邮编(ZIP):361008

电话:0592-5908028 传真:0592-5908039 咨询信箱:web@lingzhong.cn 咨询OICQ:173723134

《中华人民共和国增值电信业务经营许可证》闽B2-20100024  ICP备案:闽ICP备05037997号