Linux中SSH默认端口为22,为了安全考虑,我们有必要对22端口进行修改,现修改端口为60000;修改方法如下:
在/etc/ssh/sshd_config中找到Port 22,将其修改为60000,或使用/usr/sbin/sshd -p 60000指定端口。
如果用户想让22和60000端口同时开放,只需在/etc/ssh/sshd_config增加一行内容如下:
[[email protected] /]# vi /etc/ssh/sshd_config Port 22 Port 60000
保存并退出
[[email protected] /]#service ssh restart
Ubuntu 14.04使用的ssh在安全性上与老版本有所不同,不仅需要给root设置密码,还需要修改ssh配置允许使用root登录
1. 修改 root 密码
sudo passwd root
2. 以其他账户登录,修改 /etc/ssh/sshd_config :
[email protected]:~$ su - root Password: [email protected]:~# vi /etc/ssh/sshd_config
3. 注释掉 #PermitRootLogin without-password,添加 PermitRootLogin yes
# Authentication: LoginGraceTime 120 #PermitRootLogin without-password PermitRootLogin yes StrictModes yes
4. 重启 ssh 服务
[email protected]:~# service ssh restart ssh stop/waiting ssh start/running, process 1499 [email protected]:~#