Linux修改SSH端口,并禁止Root远程登陆

1、更改ssh远程登录端口:

#vi /etc/ssh/ssh_config
将port改为你想要的端口,例如8888.
默认是#port 22,把#号删掉改为 port 8888即可。

还要更改以下文件,更改方法同上:
#vi /etc/ssh/sshd_config

2、增加一个普通权限的用户:

#useradd 新用户
#passwd 新用户

3、禁止ROOT远程SSH登录:

#vi /etc/ssh/sshd_config
将PermitRootLogin yes一行改为:
PermitRootLogin no

4、最后重启ssh服务:

#service sshd restart或者/etc/init.d/sshd restart

这样就可以用普通账号登录ssh,如果需要的时候将sudo或su root切换来执行root权限命令。

sudo执行需要将普通用户添加到visudo文件中,具体参考:http://www.cnblogs.com/xiwang6428/p/3456830.html

原文地址:https://www.cnblogs.com/xiwang6428/p/4519948.html