美文网首页
Linux启动或禁止SSH、IP和Port的登录

Linux启动或禁止SSH、IP和Port的登录

作者: 赶时间的闹钟 | 来源:发表于2018-09-01 09:47 被阅读11次

    用户

    vim /etc/ssh/sshd_config # 编辑文件
    # `PermitRootLogin yes` 允许打开`root`用户登录,如果是服务器,必须要打开,否则,只能去**机房**操作了!
    # `AllowUsers username1 username2 username3` 允许某些用户进行`ssh`登录
    

    IP

    vim /etc/hosts.deny # 拒绝的IP
    # 先拒绝,在允许
    
    vim /etc/hosts.allow # 允许的IP
    # 添加 `sshd:192.168.220.164:allow` 
    

    端口

    vim /etc/ssh/sshd_config # 编辑文件
    # 增加 Port 22
    # 增加 Port 1234
    # 增加 Port 8908 ....
    systemctl restart sshd.service # 重启服务
    netstat  -anp | grep ssh # 查看服务
    

    Tips

    • 登录提示
    vim /etc/issue # 本地登陆显示的信息,本地登录前
    vim /etc/issue.net # 网络登陆显示的信息,登录后显示,需要由sshd配置
    vim /etc/motd # 常用于通告信息,如计划关机时间的警告等,登陆后的提示信息
    

    相关文章

      网友评论

          本文标题:Linux启动或禁止SSH、IP和Port的登录

          本文链接:https://www.haomeiwen.com/subject/vdpciftx.html