~/.rhosts文件和/etc/hosts.equiv的关系(2) 实现例

你可以有两种方法实现r命令,一是基于主机信任,另一种是基于主机加用户信任。

 

对基于主机信任方式较简单,假设LAN上有两台机器sh3和shopu,两台机器
上都有帐号jephe,你可以在sh3上设置/etc/hosts.equiv, login as root,
创建/etc/hosts.equiv,包含象下面的一行:
[root@sh3 /etc]# more hosts.equiv
shopu
[root@sh3 /etc]# ls hosts.equiv -l
-rw-rw-r-- 1 root root 6 Aug 25 08:53 hosts.equiv
其实,对于/etc/hosts.equiv,只需要读权限即可。
[root@sh3 /etc]# ls hosts.equiv -l
-r-------- 1 root root 6 Aug 25 08:53 hosts.equiv

这样的话,shopu主机上的任何用户都可以rsh sh3并不需口令。
[jephe@shopu jephe]$ rsh sh3
Last login: Wed Aug 25 09:23:36 from shopu
[jephe@sh3 jephe]$
------------------------
[jephe@shopu jephe]$ pwd
/home/jephe
[jephe@shopu jephe]$ rcp sh3:/etc/smb.conf .
[jephe@shopu jephe]$ ls -l smb.conf
-rw-r--r-- 1 jephe jephe 10694 Aug 25 09:16 smb.conf
[jephe@shopu jephe]$
-----------------------
[jephe@shopu jephe]$ rsh sh3 ls /home/ftp -l
total 4
d--x--x--x 2 root root 1024 Jul 17 04:39 bin
d--x--x--x 2 root root 1024 Jul 17 04:39 etc
drwxr-xr-x 2 root root 1024 Jul 17 04:39 lib
drwxr-sr-x 2 root ftp 1024 Mar 22 00:49 pub
[jephe@shopu jephe]$
--------------------------
主机方式可允许shopu上的任何用户无需口令访问sh3,不是很安全,
你也可以用主机加用户模式。即在sh3的/home/jephe下创建文件.rhosts,
特别需要注意的是:对.rhosts文件不能给组用户以写权限,默认情况下,
当你以用户jephe在sh3的/home/jephe目录下创建一新文件.rhosts时,
组用户有写权限,象下面这样:
[root@sh3 jephe]# ls .rhosts -l
-rw-rw-r-- 1 root root 12 Aug 25 09:34 .rhosts
[root@sh3 jephe]# more .rhosts
shopu jephe

因此,你必须去掉.rhosts文件的组用户写权限,R命令才可以正常工作。
[root@sh3 jephe]# chmod g-w .rhosts
[root@sh3 jephe]# ls .rhosts -l
-rw-r--r-- 1 root root 12 Aug 25 09:34 .rhosts
-----------------
[jephe@shopu jephe]$ rsh sh3
Last login: Wed Aug 25 09:37:05 from jephe
------------
至此,其它命令象rcp等都可以象上面介绍的一样正常使用了。

 

 

原文来自:  http://www.lyun.edu.cn/nic/net_class/linux/212.htm

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值