一、telnet命令
1.检查telnet是否有安装
#有输出说明已安装,如果没有输出则没有安装
rpm -qa telnet
#安装telnet
yum install -y telnet
#执行检查命令
[root@localhost ~]# rpm -qa telnet
[root@localhost ~]# #安装telnet
[root@localhost ~]# yum install -y telnet
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile* base: mirrors.163.com* extras: mirrors.huaweicloud.com* updates: mirrors.huaweicloud.com
Resolving Dependencies
--> Running transaction check
---> Package telnet.x86_64 1:0.17-66.el7 will be installed
--> Finished Dependency ResolutionDependencies Resolved=================================================================================================================================================================================================================Package Arch Version Repository Size
=================================================================================================================================================================================================================
Installing:telnet x86_64 1:0.17-66.el7 updates 64 kTransaction Summary
=================================================================================================================================================================================================================
Install 1 PackageTotal download size: 64 k
Installed size: 113 k
Downloading packages:
warning: /var/cache/yum/x86_64/7/updates/packages/telnet-0.17-66.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY ] 0.0 B/s | 0 B --:--:-- ETA
Public key for telnet-0.17-66.el7.x86_64.rpm is not installed
telnet-0.17-66.el7.x86_64.rpm | 64 kB 00:00:00
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Importing GPG key 0xF4A80EB5:Userid : "CentOS-7 Key (CentOS 7 Official Signing Key) <security@centos.org>"Fingerprint: 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5Package : centos-release-7-6.1810.2.el7.centos.x86_64 (@anaconda)From : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Running transaction check
Running transaction test
Transaction test succeeded
Running transactionInstalling : 1:telnet-0.17-66.el7.x86_64 1/1 Verifying : 1:telnet-0.17-66.el7.x86_64 1/1 Installed:telnet.x86_64 1:0.17-66.el7 Complete!
[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]# #检查是否安装成功
[root@localhost ~]# rpm -qa telnet
telnet-0.17-66.el7.x86_64
[root@localhost ~]#
2.检查telnet-server服务是否安装
#有输出说明已安装,如果没有输出则没有安装
rpm -qa telnet-server
#安装telnet
yum install -y telnet-server
#检查telcet-server是否安装[root@localhost ~]# rpm -qa telnet-server
[root@localhost ~]#
[root@localhost ~]# #安装telnet-server
[root@localhost ~]# yum install -y telnet-server
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile* base: mirrors.163.com* extras: mirrors.huaweicloud.com* updates: mirrors.huaweicloud.com
Resolving Dependencies
--> Running transaction check
---> Package telnet-server.x86_64 1:0.17-66.el7 will be installed
--> Finished Dependency ResolutionDependencies Resolved=================================================================================================================================================================================================================Package Arch Version Repository Size
=================================================================================================================================================================================================================
Installing:telnet-server x86_64 1:0.17-66.el7 updates 41 kTransaction Summary
=================================================================================================================================================================================================================
Install 1 PackageTotal download size: 41 k
Installed size: 55 k
Downloading packages:
telnet-server-0.17-66.el7.x86_64.rpm | 41 kB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transactionInstalling : 1:telnet-server-0.17-66.el7.x86_64 1/1 Verifying : 1:telnet-server-0.17-66.el7.x86_64 1/1 Installed:telnet-server.x86_64 1:0.17-66.el7 Complete!
[root@localhost ~]#
[root@localhost ~]# #检查telnet是否安装
[root@localhost ~]# rpm -qa telnet-server
telnet-server-0.17-66.el7.x86_64
[root@localhost ~]#
3.如果进行了telnet-server安装操作,且已成功安装,则由于telnet服务是由xinetd守护的,所以我们需要重新启动xinetd
service xinetd restart
[test@localhost ~]$ service xinetd restart
Redirecting to /bin/systemctl restart xinetd.service
==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units ===
Authentication is required to manage system services or units.
Authenticating as: root
Password: polkit-agent-helper-1: pam_authenticate failed: Authentication failure
==== AUTHENTICATION FAILED ===
Failed to restart xinetd.service: Access denied
See system logs and 'systemctl status xinetd.service' for details.
[test@localhost ~]$
[test@localhost ~]$
[test@localhost ~]$
[test@localhost ~]$
#如果执行报以上错误,则检查是否没有安装xinetd
rmp -qa xinetd
#安装xinetd
yum install -y xinetd
[root@localhost /]# rpm -qa xinetd
xinetd-2.3.15-14.el7.x86_64
[root@localhost /]#
#重启xinetd
/bin/systemctl restart xinetd.service
[root@localhost /]# /bin/systemctl restart xinetd.service
[root@localhost /]#
#xinetd启动成功,可以查看xinetd的运行情况
netstat -tnlp
4.可以ping通,但是telnet命令连接失败
[root@localhost ~]# ping 192.168.1.147
PING 192.168.1.147 (192.168.1.147) 56(84) bytes of data.
64 bytes from 192.168.1.147: icmp_seq=1 ttl=128 time=0.702 ms
64 bytes from 192.168.1.147: icmp_seq=2 ttl=128 time=1.50 ms
64 bytes from 192.168.1.147: icmp_seq=3 ttl=128 time=1.76 ms
^X64 bytes from 192.168.1.147: icmp_seq=4 ttl=128 time=1.80 ms
^C
--- 192.168.1.147 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3034ms
rtt min/avg/max/mdev = 0.702/1.442/1.804/0.443 ms
[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]# telnet 192.168.1.147 6379
Trying 192.168.1.147...
telnet: connect to address 192.168.1.147: Connection refused
可能存在情况:
1)物理网络链路不通:从A地点到B地点没有路可以走
2)防火墙没有开通相关网络:从A地点到B地点由路,但是有路障
3)目标主机没有启动:就没有B地点
我需要连接的是win系统的服务,
可以ping通,说明应该是防火墙有拦截
为指定端口设置规则:
打开win系统的防火墙设置
选择高级选项
选择入站规则,选中新建规则
选择端口、选择特定本地端口、输入端口号、选择允许连接、下一步保存
放开防火墙后,发现还是连接不上
通过查询资料发现,原来redis是开启了受保护模式
将redis.conf中的protected-mode设置为yes(保护模式),外网按理说无法访问
但是protected-mode它启用的条件有两个,第一是没有使用bind,第二是没有设置访问密码(默认没有密码),因此我们注释bind外面就访问不到了,
所以我们使用密码或者设置bind都会让保护模式失效,这样外网就能访问到。
127.0.0.1:6379>
127.0.0.1:6379>
127.0.0.1:6379> config get "protected-mode"
1) "protected-mode"
2) "yes"
127.0.0.1:6379> config set "protected-mode" no
OK
127.0.0.1:6379> config get "protected-mode"
1) "protected-mode"
2) "no"
127.0.0.1:6379>
5.切换用户
#当安装某些工具时,没有权限,需要切换用户
You need to be root to perform this command.
#需要root超级管理员权限才能执行特定命令,执行以下命令切换用户
su
此时需要输入密码
You need to be root to perform this command.
[test@localhost /]$ su
Password:
[root@localhost /]#