我正在运行带有 WHM 和 CSF 防火墙的 CENTOS Web 服务器。我正在尝试从默认端口更改 SSH。我已经在 CSF 中打开了端口并修改了/etc/ssh/sshd_config取消注释端口行并将其更改为我希望它打开的端口。然后我使用 WHM 和命令行重新启动了 SSH,然后它重新启动。但是,当它重新启动时,它仍然使用默认端口 22。我做错了什么?
sshd_config 文件中的设置:
# Host *
# ForwardAgent no
# ForwardX11 no
# RhostsRSAAuthentication no
# RSAAuthentication yes
# PasswordAuthentication yes
# HostbasedAuthentication no
# GSSAPIAuthentication no
# GSSAPIDelegateCredentials no
# GSSAPIKeyExchange no
# GSSAPITrustDNS no
# BatchMode no
# CheckHostIP yes
# AddressFamily any
# ConnectTimeout 0
# StrictHostKeyChecking ask
# IdentityFile ~/.ssh/identity
# IdentityFile ~/.ssh/id_rsa
# IdentityFile ~/.ssh/id_dsa
Port 2222
# Protocol 2,1
# Cipher 3des
# Ciphers aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc
# MACs hmac-md5,hmac-sha1,umac-64@openssh.com,hmac-ripemd160
# EscapeChar ~
# Tunnel no
# TunnelDevice any:any
# PermitLocalCommand no
# VisualHostKey no
Host *
Run Code Online (Sandbox Code Playgroud)
然后这是我控制台的副本,以便您可以看到我运行的内容:
root@vps1 [~]# cd /etc/ssh
root@vps1 [/etc/ssh]# vi ssh_config
root@vps1 [/etc/ssh]# /etc/init.d/sshd restart
Stopping sshd: [ OK ]
Starting sshd: [ OK ]
root@vps1 [/etc/ssh]#
Run Code Online (Sandbox Code Playgroud)
然后我跑去netstat -tuplen检查它运行的端口:
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 0 36862521 8315/sshd
Run Code Online (Sandbox Code Playgroud)
仍在端口 22 上运行。
您在问题中所拥有的不是 a sshd_configthat is a ssh_config。
您需要进行编辑,sshd_config然后重新启动sshd。
ssh_config 是客户端配置,对守护程序设置没有影响。