> Linux故障 >

阿里云服务器 22端口无法访问

 发现xshell连接不上服务器, 扫描服务器端口发现只有21 两个端口是开启的,22端口莫名被关闭了。 

        

vim /etc/sysconfig/iptables

编辑iptables,添加: 
-A INPUT -m state –state NEW -m tcp -p tcp –dport 22 -j ACCEPT 
-A INPUT -m state –state NEW -m tcp -p tcp –dport 8080 -j ACCEPT 

1
<span style="font-family: 'Microsoft YaHei'; font-size: 12px;">/etc/init.d/sshd restart</span>

保存退出,重启服务。

 

问题显示如下:

  /var/empty/sshd must be owned by root and not group or world-writable.

    查看状态

     /etc/init.d/sshd status

  sshd is stopped

  手工启动服务,发现报告权限错误。

   /etc/init.d/sshd start

  Starting sshd:/var/empty/sshd must be owned by root and not group or world-writable.

 

  使用rpm -V 命令可检查到ssh的软件包正常,但某个目录的属主错误。

  -bash-2.05b# rpm -V openssh-server

  S.5….. c /etc/ssh/sshd_config

  …..U.. /var/empty/sshd

 

  经查看发现这个目录的属主不是root,所以启动ssh报错

    ls -ld /var/empty/sshd/

  d–x–x–x 2 mysql mysql 1024 Feb 2 2005 /var/empty/sshd/

 

     修改为root属主,启动成功

   chown root /var/empty/sshd/

   /etc/init.d/sshd start

  Starting sshd: [ OK ]  

  另外,还可以尝试:  这个是权限的问题 

  chown -R root.root /var/empty/sshd

  chmod 744 /var/empty/sshd

  service sshd restart

  

 




(责任编辑:IT)