日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > linux >内容正文

linux

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

發布時間:2024/7/23 linux 43 豆豆
生活随笔 收集整理的這篇文章主要介紹了 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 <目標服務,例如: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

總結

以上是生活随笔為你收集整理的Linux的Xshell连接Centos7能Ping通但无法连接问题[ssh(d)+firewall(d)]【转载转载转载】的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。