linux限制IP访问ssh

 

在/etc/hosts.allow输入   
(其中192.168.10.88是你要允许登陆ssh的ip,或者是一个网段192.168.10.0/24)   
sshd:192.168.10.88:allow   
    
在/etc/hosts.deny输入(表示除了上面允许的,其他的ip   都拒绝登陆ssh)   
sshd:ALL

更改端口
vi /etc/ssh/sshd_config
port 3333

最后一行加上ip
allowusers root@ip   ------------------允许某个ip用什么帐户登陆

实际示例:

  1. cat /etc/hosts.allow
  2. #
  3. # hosts.allow This file contains access rules which are used to
  4. # allow or deny connections to network services that
  5. # either use the tcp_wrappers library or that have been
  6. # started through a tcp_wrappers-enabled xinetd.
  7. #
  8. # See 'man 5 hosts_options' and 'man 5 hosts_access'
  9. # for information on rule syntax.
  10. # See 'man tcpd' for information on tcp_wrappers
  11. #
  12. sshd:192.168.0.0/:allow
  13. sshd:172.20.18.0/:allow
  14. sshd:10.8.0.0/:allow
  1. cat /etc/hosts.deny
  2. #
  3. # hosts.deny This file contains access rules which are used to
  4. # deny connections to network services that either use
  5. # the tcp_wrappers library or that have been
  6. # started through a tcp_wrappers-enabled xinetd.
  7. #
  8. # The rules in this file can also be set up in
  9. # /etc/hosts.allow with a 'deny' option instead.
  10. #
  11. # See 'man 5 hosts_options' and 'man 5 hosts_access'
  12. # for information on rule syntax.
  13. # See 'man tcpd' for information on tcp_wrappers
  14. #
  15. sshd:ALL

systemctl restart sshd

验证只能内网登录 ,外网无法登录

SSH限制ip登陆的更多相关文章

  1. CentOS只允许部分IP登陆ssh |ssh 允许指定IP

    在/etc/hosts.allow输入   (其中192.168.10.88是你要允许登陆ssh的ip,或者是一个网段192.168.10.0/24)   sshd:192.168.10.88:all ...

  2. 如何设置ssh安全只允许用户从指定的IP登陆

    原文链接: 如何设置ssh安全只允许用户从指定的IP登陆 由于开发上传文件需要  在服务器上开启  允许用户名和密码ssh登录.这样不太安全.百度后参考文章现在ssh用户名和密码登录的ip. 登录服务 ...

  3. 设置ssh只允许用户从指定的IP登陆

    假设 我们公司的固定IP是  183.21.89.249   连接上我们自己进行管理的服务器   然后编辑ssh的配置文件默认  /etc/ssh/sshd_config   在文件最后面另起一行添加 ...

  4. 学习如何设置ssh安全只允许用户从指定的IP登陆

    参考原文链接:https://www.cnblogs.com/wuling129/p/5076081.html 因为在公司做项目时,员工的登录可能受到外界人的窃取,为了防止被攻击,设置系统只能允许用户 ...

  5. centos7设置SSH安全策略–指定IP登陆

    之前自己搭建了个博客网站(理想三旬),写了些文章,但是由于一些原因慢慢将文章放在博客园了.所以这里将一些文章复制过来.便于以后自己查询. 为了服务器的安全性,我们在日常使用需要授予权限和指定ip登陆来 ...

  6. 正式生产环境下hadoop集群的DNS+NFS+ssh免password登陆配置

    博客地址:http://www.loveweir.com/ 环境虚拟机centos6.5 主机名h1  IP 192.168.137.11  作为DNS FNS的server 主机名h2  IP 19 ...

  7. ssh免密登陆配置

    目录 ssh免密登陆 在A工作站上输入 B服务器上输入 登陆 ssh初次登陆询问 1.单次取消 2.ansible中增加链接参数 3.修改ansible配置参数[推荐] 4.修改服务器上的ssh_co ...

  8. Linux中ssh介绍与ssh+key密钥登陆部署

    环境内核信息: [root@zabbix- ~]# uname -a Linux zabbix- -.el6.x86_64 # SMP Tue Mar :: UTC x86_64 x86_64 x86 ...

  9. Linux Hadoop集群搭建第二步:--------SSH免密登陆

    内容和Linux 搭建 Hadoop集群--Jdk配置相关联 三台虚拟机的操作 Linux SSH免密登陆: 参考网址:http://www.cnblogs.com/999-/p/6884861.ht ...

随机推荐

  1. [CODE FESTIVAL 2017]Poor Penguin

    题意:在一个$n\times m$的网格上,每个格子是薄冰或冰山(网格外什么都没有),有一片薄冰上站着一只企鹅,对于薄冰$(i,j)$,如果不满足($(i-1,j),(i+1,j)$都有东西或$(i, ...

  2. 【数论】【莫比乌斯反演】【线性筛】bzoj2005 [Noi2010]能量采集

    http://blog.csdn.net/Clove_unique/article/details/51089272 Key:1.连接平面上某个整点(a,b)到原点的线段上有gcd(a,b)个整点. ...

  3. 【动态规划】【二分】Petrozavodsk Winter Training Camp 2017 Day 1: Jagiellonian U Contest, Monday, January 30, 2017 Problem B. Dissertation

    题意: 给定S1串,长度100w,S2串,长度1k.问它俩的LCS. f(i,j)表示S2串前i个字符,LCS为j时,最少需要的S1串的前缀长度.转移的时候,枚举下一个字符在S1的位置即可.(可以预处 ...

  4. 【扩展欧几里得】Codeforces Round #406 (Div. 2) A. The Monster

    扩欧,a+bx=c+dx,输出x>=0且y>=0,且a+bx最小的解. 要注意不能只保证x非负,还得看看能否保证y也非负. #include<cstdio> #include& ...

  5. Codeforces Gym 100269B Ballot Analyzing Device 模拟题

    Ballot Analyzing Device 题目连接: http://codeforces.com/gym/100269/attachments Description Election comm ...

  6. Delphi DevExpress下载

    http://download.csdn.net/detail/wozengcong/8395285#comment

  7. Java 8:不要再用循环了 Stream替代for循环

    原文:http://www.importnew.com/14841.html 在这篇文章里,我们将会去了解传统循环的一些替代方案.在Java 8的新功能特性中,最棒的特性就是允许我们去表达我们想要完成 ...

  8. mysql 中添加索引的三种方法

    原文:http://www.andyqian.com/2016/04/06/database/mysqleindex/ 在mysql中有多种索引,有普通索引,全文索引,唯一索引,多列索引,小伙伴们可以 ...

  9. Ceph源码解析:Scrub故障检测

    转载请注明出处 陈小跑 http://www.cnblogs.com/chenxianpao/p/5878159.html 本文只梳理了大致流程,细节部分还没搞的太懂,有时间再看,再补充,有错误请指正 ...

  10. $stateProvider resovle 无法找到的原因

    $stateProvider 在写resolve的时候,也要写上controller,不能直接在页面上用ng-controller 来指定!!!! 不然的话,就是报依赖注入异常,找不到该provide ...