xshell无法ping通linux,[Linux]Xshell连接Centos7能Ping通但无法连接问题[ssh(d)+firewall(d)]...

一 方案与思路

0 xshell客户端监测是否能够ping通目标服务器。

前提:知晓目标服务器IP地址

Linux: ifconfig -a

Windows: ipconfig -a

1 利用firewall工具,检查是否已开启ssh的22端口。若无,则:开启22端口

2 利用sshd工具,检查是否已开启sshd服务。若无,则:开启sshd服务

开(重)启ssh服务: system (re)start sshd

3 利用systemctl工具,检查是否已开启sshd、firewalld的开机自启服务。若无,则:开启sshd、firewalld服务的开机自启

systemctl enable sshd

systemctl list-unit-files | grep sshd

systemctl enable firewalld[.service]

systemctl list-unit-files | grep firewall

二 相关知识及操作命令

关键工具

ssh:客户端,主要进行服务器端的连接

sshd:服务端,作用于服务器端(开闭ssh服务等操作)

ssh————————————>sshd

client      serve

firewalld(防火墙)

firwall-cmd(Linux提供的操作firewall的一个工具)

systemctl(服务控制命令)

1 sshd

查看服务状态

inactive(不可用),active(可用,活动状态)

systemctl status sshd

列出已开启服务当前状态

systemctl list-units | grep

netstat -antulp | grep ssh

3d8577bc446536d9f2c8cb5d06db72c1.png

开启ssh服务

systemctl start sshd

设定服务开机启动

systemctl enable sshd

查看sshd开机自启服务是否已开启

systemctl list-unit-files | grep sshd

关闭ssh服务

systemctl stop sshd

设定服务开机不启动

systemctl disable sshd

重启ssh服务

systemctl restart sshd

重新加载服务配置

systemctl reload sshd

2 防火墙

2.1 查看

查看firewall服务状态

systemctl status firewalld

10c3e96a3bc52a1609d4ee0bd4dd0fc5.png

查看防火墙状态

firewall-cmd --state

2d01cdebe5cda59932f8e7524e792a99.png

查看防火墙规则

firewall-cmd --list-all

c497310212e076a2be48b16e065e999a.png

76b9d38ddeff9b19932eb8078b98f4ac.png

查询端口是否开放

firewall-cmd --query-port=8080/tcp

2.2 操纵

1.2.1 firewall端口

开放端口

例如,80端口

--permanent:表示设置为持久;

--add-port:标识添加的端口;

firewall-cmd --permanent --add-port=80/tcp

移除端口

firewall-cmd --permanent --remove-port=8080/tcp

1.2.2 firewall服务

开启

service firewalld start

重启

service firewalld restart

# 或者↓

firewall-cmd --reload 【重启防火墙(修改配置后,要重启防火墙)】

启用/禁用 开机自启

systemctl enable/disable firewalld.service

关闭

service firewalld stop

2.3 补充: CentOS6的防火墙操作

# 查看防火墙状态

service iptables status

# 停止防火墙

service iptables stop

# 启动防火墙

service iptables start

# 重启防火墙

service iptables restart

# 永久关闭防火墙

chkconfig iptables off

# 永久关闭后重启

chkconfig iptables on

3 参考文档

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值