1. 实验环境
两台主机均为最小化安装的centos7操作系统,
主机名 | IP地址 |
---|---|
host-134 | 192.168.153.134 |
host-135 | 192.168.153.135 |
实验之前关闭两台主机的防火墙和selinux
2. 在两台主机上均安装所需的服务
yum -y install rsh rsh-server xinetd ntsysv
3. 命令输入 ntsysv
回车之后开启图形界面管理模式来设置开机启动
在打开的服务中找到rlogin和rsh,按空格键在两项服务之前加上*号,添加之后按tab键选中Ok 回车退出
4. 重启xinetd服务
systemctl restart xinetd
5. 在两台主机上均编写rsh和rlogin的配置文件,配置文件内容相同
[root@host-134 xinetd.d]# cat /etc/xinetd.d/rsh
#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 = no
}
[root@host-134 xinetd.d]# cat /etc/xinetd.d/rlogin
# default: on
# description: rlogind is the server for the rlogin(1) program. The server \
# provides a remote login facility with authentication based on \
# privileged port numbers from trusted hosts.
service login
{
socket_type = stream
wait = no
user = root
log_on_success += USERID
log_on_failure += USERID
server = /usr/sbin/in.rlogind
disable = no
}
6. 在两台主机上均修改 /etc/securetty
配置文件,在文件默认加一下3行
rexec
rsh
rlogin
7. 在两台主机上均编辑/etc/hosts,添加两主机的ip,主机名
[root@host-134 ~]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.153.134 host-134
192.168.153.135 host-135
[root@host-135 ~]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.153.134 host-134
192.168.153.135 host-135
8. 修改~/.rhosts ,添加两个主机的主机名,ip
[root@host-135 ~]# cat ~/.rhosts
host-134 root
host-135 root
[root@host-134 ~]# cat ~/.rhosts
host-134 root
host-135 root
9. 重启xinetd服务并设为开机自启
systemctl restart xinetd
systemctl enable xinetd
10. 登录测试
134 主机登录 135 主机
[root@host-134 ~]# rsh host-135
Last login: Fri Jan 22 15:36:08 from host-134
[root@host-135 ~]#
135 主机登录 134 主机
[root@host-135 ~]# rsh host-134
Last login: Fri Jan 22 14:05:29 from host-135
[root@host-134 ~]#
11. 传输文件测试
将134主机上的134.txt文件传输到135主机上的/root目录下
rcp /root/134.txt host-135:/root
在135主机上验证
[root@host-135 ~]# ls
134.txt
将135主机上的test目录下的子文件和子目录传输到135主机上的/root目录下
rcp -r /root/test host-134:/root
验证:
[root@host-134 ~]# tree test/
test/
├── test_1
├── test1.txt
├── test_2
└── test2.txt
2 directories, 2 files