红联Linux门户
Linux帮助

Linux下配置RSH&RCP

发布时间:2011-06-02 22:26:06来源:红联作者:haizdl@126.com
Linux下配置RSH&RCP




1首先确认机器是否安装RSH包
[oracle@linux ~]$ rpm -aq |grep rsh

rsh-0.17-25.4

rsh-server-0.17-25.4



如果没有安装以上两个安装包:

rpm -ivh rsh-0.17-5 (linux 操作系统)

rpm -ivh rsh-server-0.17-5 (linux 操作系统)



2修改/etc/xinetd.d/rsh脚本文件
[root@linux ~]# vi /etc/xinetd.d/rsh

修改/etc/xinetd.d/rsh脚本文件文件中的选项,将disable 设置为no

# default: on

# description: The rshd server is the server for the rcmd(3) routine and, \

# consequently, for the rsh(1) program. The server provides \

# remote execution facilities with authentication based on \

# privileged port numbers from trusted hosts.

service shell

{

socket_type = stream

wait = no

user = root

log_on_success += USERID

log_on_failure += USERID

server = /usr/sbin/in.rshd

# disable = yes

disable = no

}



3重启RSH服务
[root@linux ~]# service xinetd restart

Stopping xinetd: [ OK ]

Starting xinetd: [ OK ]



4检查是否启动RSH服务
TCP 是514。

[root@linux ~]# netstat -an |grep 514

tcp 0 0 0.0.0.0:514 0.0.0.0:* LISTEN

unix 3 [ ] STREAM CONNECTED 44514



5配置RSH服务
修改/etc/securetty文件: echo rsh >>/etc/securetty

如果打算用root作为rsh用户的话:

先用root登录到机器A中进行以下操作:

[root@linux ~]# echo "192.168.7.10 root" >>.rhosts

//允许192.168.0.10 以root访问

[root@linux ~]# echo "192.168.7.15 root" >>.rhosts



重启rsh server.

.rhosts一般位于 rsh服务器相对应账号目录下.

查看是否配置成功:

[root@linux ~]# more .rhosts

192.168.7.10 root

192.168.7.15 root



6配置/etc/hosts,加入对方的IP&hostname
机器名可以参考127.0.0.1一行。

[root@linux ~]# vi /etc/hosts



# Do not remove the following line, or various programs

# that require network functionality will fail.

127.0.0.1 linux localhost.localdomain localhost

192.168.7.15 linux #本机ip及机器名

192.168.7.10 hlht #远程服务器ip及机器名



7配置vi /etc/hosts.equiv
[root@linux ~]# vi /etc/hosts.equiv

127.0.0.1 localhost

192.168.7.10 hlht

192.168.7.15 linux



8到/etc/pam.d/目录下的rsh文件修改。
把rsh文件中的auth required pam_securetty.so一行用“#”封掉即可

(注意修改红色字体一行:加“#”)



[root@hlht ~]# cd /etc/pam.d

[root@hlht pam.d]# vi rsh

#%PAM-1.0

# For root login to succeed here with pam_securetty, "rsh" must be

# listed in /etc/securetty.

auth required pam_nologin.so

#auth required pam_securetty.so

auth required pam_env.so

auth required pam_rhosts_auth.so

account required pam_stack.so service=system-auth

session required pam_stack.so service=system-auth



9重启RSH服务器
[root@linux ~]# service xinetd restart

Stopping xinetd: [ OK ]

Starting xinetd: [ OK ]



10 RSH服务测试
登录到192.168.7.10机器进行测试,看是否能看到结果。

如果看到

[oracle@linux ~]$ rsh -l oracle 192.168.7.10 ps -ef

connect to address 192.168.7.10: Connection refused

Trying krb4 rsh...

connect to address 192.168.7.10: Connection refused

trying normal rsh (/usr/bin/rsh)

Permission denied.

这是由于权权限问题,一般是由于 .rhosts没有配置正确。

.rhosts一般位于rsh server服务器相对应账号目录下。



如果看到

[root@linux pam.d]# rsh -l root 192.168.7.10 env|grep PATH

connect to address 192.168.7.10: Connection refused

Trying krb4 rsh...

connect to address 192.168.7.10: Connection refused

trying normal rsh (/usr/bin/rsh)

PATH=/usr/kerberos/sbin:/usr/kerberos/bin:/usr/bin:/bin

表示rsh配置成功,可以使用rcp进行远程拷贝。



11 RCP远程目录拷贝
[root@hlht run]# rcp -r source linux:/opt/oracle/yljs

//linux为刚才配置的192.168.7.15服务器名

connect to address 192.168.7.15: Connection refused

Trying krb4 rcp...

connect to address 192.168.7.15: Connection refused

trying normal rcp (/usr/bin/rcp)

[root@hlht run]#
文章评论

共有 2 条评论

  1. rxotav 于 2011-06-03 08:41:00发表:

    路过学习

  2. haizdl@126.com 于 2011-06-02 22:27:08发表:

    现在用的不多了,不安全