1.准备两台linux服务器,一台为服务器端,一台为客户端,为服务器配置静态ip地址,配置两台服务器网络通信正常:
[root@localhost ~]# vim /etc/sysconfig/network-scripts/ifcfg-ens33

[root@localhost ~]# systemctl restart network
[root@localhost ~]# ping baidu.com
PING baidu.com (220.181.38.148) 56(84) bytes of data.
64 bytes from 220.181.38.148 (220.181.38.148): icmp_seq=1 ttl=128 time=33.5 ms
64 bytes from 220.181.38.148 (220.181.38.148): icmp_seq=2 ttl=128 time=39.4 ms
64 bytes from 220.181.38.148 (220.181.38.148): icmp_seq=3 ttl=128 time=50.4 ms
2.关闭防火墙和selinux:
[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# setenforce 0
3.请在linux服务器端安装配置telnet服务,并将telnt服务设置为开机自动启动:
[root@localhost ~]# yum -y install telnet-server
[root@localhost ~]# yum -y install xinetd
[root@localhost ~]# systemctl enable xinetd.service
[root@localhost ~]# systemctl start xinetd
[root@localhost ~]# systemctl enable telnet.socket
Created symlink from /etc/systemd/system/sockets.target.wants/telnet.socket to /usr/lib /systemd/system/telnet.socket.
[root@localhost ~]# systemctl restart telnet.socket
4.请创建一个普通用户test,以远程登录使用:
[root@localhost ~]# useradd test
[root@localhost ~]# passwd test
更改用户 test 的密码 。
新的 密码:
无效的密码: 密码少于 8 个字符
重新输入新的 密码:
passwd:所有的身份验证令牌已经成功更新。
5.请在linux客端端安装telnet客户端,并使用telnet客户端远程登录到linux服务器端操作,登录成功:
[root@localhost ~]# yum -y install telnet
[root@localhost ~]# telnet 192.168.136.188
4Trying 192.168.136.188...
Connected to 192.168.136.188.
Escape character is '^]'.
Kernel 3.10.0-862.el7.x86_64 on an x86_64
4localhost login: test
Password:
[test@localhost ~]$
6.可以继续使用上题的两台linux服务器,请在Linux服务器端检查ssh服务状态是否为启动,并检查sshd服务是否为开机自启:
[root@localhost ~]# netstat -anltp |grep ssh
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1098/ss hd
tcp 0 0 127.0.0.1:6010 0.0.0.0:* LISTEN 4295/ss hd: root@pts
tcp 0 0 192.168.136.189:22 192.168.136.1:51396 ESTABLISHED 4303/ss hd: root@not
tcp 0 0 192.168.136.189:22 192.168.136.1:51395 ESTABLISHED 4295/ss hd: root@pts
tcp6 0 0 :::22 :::* LISTEN 1098/ss hd
tcp6 0 0 ::1:6010 :::* LISTEN 4295/ss hd: root@pts
[root@localhost ~]# systemctl status sshd
● sshd.service - OpenSSH server daemon
Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled; vendor preset: enable d)
Active: active (running) since 二 2020-06-09 20:30:41 CST; 1 weeks 6 days ago
Docs: man:sshd(8)
man:sshd_config(5)
Main PID: 1098 (sshd)
Tasks: 1
CGroup: /system.slice/sshd.service
└─1098 /usr/sbin/sshd -D
6月 09 20:30:41 localhost.localdomain systemd[1]: Starting OpenSSH server daemon...
6月 09 20:30:41 localhost.localdomain sshd[1098]: Server listening on 0.0.0.0 port 22.
6月 09 20:30:41 localhost.localdomain sshd[1098]: Server listening on :: port 22.
6月 09 20:30:41 localhost.localdomain systemd[1]: Started OpenSSH server daemon.
6月 23 14:48:11 localhost sshd[4295]: Address 192.168.136.1 maps to localhost, bu...T!
6月 23 14:48:14 localhost sshd[4295]: Accepted password for root from 192.168.136...h2
6月 23 14:48:14 localhost sshd[4303]: Address 192.168.136.1 maps to localhost, bu...T!
6月 23 14:48:15 localhost sshd[4303]: Accepted password for root from 192.168.136...h2
Hint: Some lines were ellipsized, use -l to show in full.
7.请在linux客户端通过ssh,使用test用户远程登录测试:
[root@localhost ~]# ssh test@192.168.136.188
The authenticity of host '192.168.136.188 (192.168.136.188)' can't be established.
ECDSA key fingerprint is SHA256:QYnlvw7A4nCkcNzJSgr1HTCR3Dx3e9+EOYU9xmqPt8c.
ECDSA key fingerprint is MD5:6d:34:af:19:a0:85:d4:35:70:16:59:9d:cf:34:5e:64.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.136.188' (ECDSA) to the list of known hosts.
test@192.168.136.188's password:
Last login: Tue Jun 23 15:13:18 2020 from ::ffff:192.168.136.189
[test@localhost ~]$
本文详细介绍了如何在Linux环境下配置Telnet服务,包括安装、设置开机启动、创建用户等步骤,以及如何从客户端进行远程连接。同时,还演示了SSH服务的状态检查和开机自启设置,以及使用SSH进行远程登录的全过程。
1165

被折叠的 条评论
为什么被折叠?



