阿里云轻量应用服务器环境搭建-设置服务器只能通过固定IP登录
阿里云轻量应用服务器环境搭建-设置服务器只能通过固定IP登录
参考链接:https://blog.csdn.net/a898712940/article/details/89489069 、
https://blog.csdn.net/jj546630576/article/details/80634922?utm_medium=distribute.pc_relevant_t0.none-task-blog-BlogCommendFromMachineLearnPai2-1.channel_param&depth_1-utm_source=distribute.pc_relevant_t0.none-task-blog-BlogCommendFromMachineLearnPai2-1.channel_param
-
使用XShell登录服务器
-
使用who命令查看当前登录的IP
-
通过阿里云在浏览器中远程连接,查看其IP
-
随便在哪个连接中编辑
/etc/ssh/sshd_config
注:第二行命令中@后面即为上面通过who命令查到的IP地址,请根据自己查询的结果输入
vi /etc/ssh/sshd_config
# 添加如下语句
AllowUsers root@111.222.333.444 admin@11.22.33.44
- 删除
PubkeyAuthentication yes前面的注释
- 不允许密码登录
PasswordAuthentication no
- 重启sshd服务
service sshd restart
- ok,现在服务器只能通过上面的两个IP通过ssh的方式登录
创作不易,喜欢的话加个关注点个赞,谢谢谢谢谢谢谢。
