Linux SSH service is always open, easy to be invaded by others, want to manage this service, you have to change the following this bold red file
[Email protected] ~]# cd/etc/ssh/
[[email protected] ssh]# ls
Moduli ssh_config sshd_config ssh_host_dsa_key ssh_host_dsa_key.pub ssh_host_key ssh_host_key.pub ssh_host_ Rsa_key ssh_host_rsa_key.pub
Edit this file:
Remember to back up before editing and develop good habits
[email protected] ssh]# CP sshd_config Sshd_config.ori #备份配置文件
[Email protected] ~]# VI sshd_config
Modify the following:
#Port #这个是SSH的端口, can be changed to the other port (0-65535) before the # number removed, the result: Port 63351
#PermitEmptyPasswords no #这个的意思是是否允许空密码登陆 to remove the # option, this is the default cannot use a blank password, result: Permitemptypasswords No
#UseDNS yes this is to not use DNS this does not use, #号去掉, yes to No, result: usedns Yes No
#PermitRootLogin Yes this is the default allows the root user ssh login, if you want to be safe, can be changed to not allow, result: Permitrootlogin No
Basically, these four items are changed.
After the completion of the SSH service with restart, the command is as follows:
[Email protected] ssh]#/etc/init.d/sshd restart
stopping sshd: [OK]
Starting sshd: [OK]
Small problem : If you are not connected with a normal user, you can shut down the firewall in the Linux system, the command is as follows:
[[email protected] ssh]#/etc/init.d/iptables stop
Iptables:setting chains to Policy Accept:filter [OK]
iptables:flushing firewall rules: [OK]
iptables:unloading modules: [OK]
# You can use: Netstat-an to view all the devices connected to the system. If the current user is logged into the system with root via the SSH service, the connection will not be logged.
At last:
If you want to change back, directly with the file you just backed up, back on the OK.
Linux Security management: SSH Management