1000字范文,内容丰富有趣,学习的好帮手!
1000字范文 > Linux的Xshell连接Centos7能Ping通但无法连接问题[ssh(d)+firewall(d)]【转载转载转载】

Linux的Xshell连接Centos7能Ping通但无法连接问题[ssh(d)+firewall(d)]【转载转载转载】

时间:2023-02-28 02:39:43

相关推荐

Linux的Xshell连接Centos7能Ping通但无法连接问题[ssh(d)+firewall(d)]【转载转载转载】

一 方案与思路

0 xshell客户端监测是否能够ping通目标服务器。 前提:知晓目标服务器IP地址 Linux: ifconfig -aWindows: ipconfig -a1 利用firewall工具,检查是否已开启ssh的22端口。若无,则:开启22端口2 利用sshd工具,检查是否已开启sshd服务。若无,则:开启sshd服务 开(重)启ssh服务: system (re)start sshd3 利用systemctl工具,检查是否已开启sshd、firewalld的开机自启服务。若无,则:开启sshd、firewalld服务的开机自启 systemctl enable sshdsystemctl list-unit-files | grep sshdsystemctl 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 <目标服务,例如:ssh>或netstat -antulp | grep ssh

开启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

查看防火墙状态

firewall-cmd --state

查看防火墙规则

firewall-cmd --list-all

查询端口是否开放

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

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。