方法一:
首先需要限制登錄的ip(或者如果需要自己本地登錄,查看最后登錄ip即可)
vim /etc/hosts.allow
輸入
sshd:114.80.100.159:allow
vim /etc/hosts.deny
輸入(表示除了上面允許的,其他的ip 都拒絕登陸ssh)
sshd:all
最后sshd重啟
service sshd restart
方法二:
比如說(shuō)你只允許114.80.100.159這個(gè)ip進(jìn)入,其它都禁止:
vim /etc/ssh/sshd_config
添加一行:
allowusers [email protected]
注:xxx為你用來(lái)登入服務(wù)器的用戶名
最后sshd重啟
service sshd restart