修改centos和ubuntu ssh远程连接端口提升系统安全性

#修改centos服务器ssh端口

sed -i 's/#Port 22/Port 38390/' /etc/ssh/sshd_config
sed -i 's/^GSSAPIAuthentication yes$/GSSAPIAuthentication no/' /etc/ssh/sshd_config
service sshd restart

#修改centos服务器root密码

echo '8bdafafffe' | passwd --stdin root


发现sshd无法启动


UseDNS no
#AddressFamily inet
PermitRootLogin yes
SyslogFacility AUTHPRIV
PasswordAuthentication yes


vim /etc/ssh/sshd_config


修改如下:


ListenAddress 1.1.1.1


重启sshd报错:
service sshd restart
Stopping sshd:                                             [FAILED]
Starting sshd: /etc/ssh/sshd_config line 130: address family must be specified before ListenAddress.
                                                           [FAILED]
于是将sshd_config底部的AddressFamily inet提至ListenAddress前面即可:


Port 38390
AddressFamily inet
ListenAddress 1.1.1.1


ubuntu ssh端口修改方法
sed -i 's/Port 22/Port 38390/' /etc/ssh/sshd_config
sed -i 's/^GSSAPIAuthentication yes$/GSSAPIAuthentication no/' /etc/ssh/sshd_config

service ssh restart


密码修改方法

sudo passwd

 

posted @ 2016-08-16 16:42  reblue520  阅读(677)  评论(0编辑  收藏  举报