1.先关闭防火墙禁止开机自启,要不会有不必要的麻烦。

systemctl stop firewalld.service systemctl disable firewalld.service 2.改SSH默认远程端口,默认使用22端口是很危险的。

配置文件在/etc/ssh/sshd_config,编辑此文件。 vi /etc/ssh/sshd_config

找到Port,一般默认是22,前面有#号的话去掉,把22变成你想改的,wq保存并推出。重启ssh服务或者重启服务器。 systemctl restart sshd.service 3.创建新用户并授root权限

创建一个用户,例如gyuryong。 adduser gyuryong

为用户初始化密码。 passwd gyuryong

授予root权限,个人用户的权限只可以在本home下有完整权限,所以我们经常要sudo为root来操作,配置文件在/etc/sudoers,正常好像只有读的权限。 先赋予w权限。 chmod 777 /etc/sudoers 然后编辑文件。 vi /etc/sudoers 找到root ALL=(ALL) ALL在下面按格式追加一行。 gyuryong ALL=(ALL) ALL wq保存并推出,重新改回只读权限。 chmod 444 /etc/sudoers 禁止root登入,配置文件在/etc/ssh/sshd_config。 vi /etc/ssh/sshd_config 找到PermitRootLogin yes,yes改为no,wq保存并推出,reboot重启服务器测试吧。

https://www.gyuryong.com/index.php/archives/18/