zoukankan      html  css  js  c++  java
  • SSH配置文件

    一 ssh配置文件路径

    1.1 ssh客户端配置文件:

    路径:/etc/ssh/ssh_config

    1.2 ssh服务端配置文件:

    路径:/etc/ssh/sshd_config

    二 服务器端常用配置选项

    2.1 常见配置项

     1 Port 22 #端口
      2 
      3 ListenAddress #监听的IP
      4 
      5 Protocol 2 #SSH版本选择
      6 
      7 HostKey /etc/ssh/ssh_host_rsa__key #私钥保存位置
      8 
      9 ServerKeyBits #1024
     10 
     11 ServerFacility AUTH #日志记录ssh登陆情况
     12 
     13 #KeyRegenerationInterval 1h #重新生成服务器密钥的周期
     14 
     15 #ServerKeyBits 1024 #服务器密钥的长度
     16 
     17 LogLevel INFO #记录sshd日志消息的级别
     18 
     19 #PermitRootLogin yes #是否允许root远程ssh登录
     20 
     21 #RSAAuthentication yes #设置是否开启ras密钥登录方式
     22 
     23 #PubkeyAuthentication yes #设置是否开启公钥验登录方式
     24 
     25 #AuthorizedKeysFile .ssh/authorized_keys #设置公钥验证文件的路径
     26 
     27 #PermitEmptyPasswords no #设置是否允许空密码的账号登录
     28 
     29 X11Forwarding yes #设置是否允许X11转发
     30 
     31 GSSAPIAuthentication yes #GSSAPI认证开启

    2.3 默认端口修改

    注意:ssh默认端口号,建议修改为其他非常用端口。

     1 #Port 22                            #这行加#号注释掉
      2 Port 2222                              #下面添加这一行

    2.4 监听IP地址

     1 ListenAddress

    监听的IP,允许某些特定的IP才可以ssh登陆进来。

    2.5 采用SSH协议版本

    1 Protocol 2

    默认的ssh版本,建议采用第二代版本。

    2.6 私钥配置

    1 HostKey /etc/ssh/ssh_host_rsa__key
      2 # HostKeys for protocol version 2
      3 HostKey /etc/ssh/ssh_host_rsa_key
      4 #HostKey /etc/ssh/ssh_host_dsa_key

    版本v2的私钥保存路径。

    2.7 加密位

     1 ServerKeyBits 1024

    钥匙串的加密位数,默认采用1024位加密。

    2.8 日志等级

    1 ServerFacility AUTH & LogLevel INFO

    需要记录日志,并设定日志等级为INFO,建议不用修改。

    2.9 GGSSAP认证

     1 GGSSAPIAuthentication yes

    GGSSAP认证默认已开启,经过dns进行认证,尝试将主机IP和域名进行解析。若管理主机无对外域名,建议在管理主机上在客户端的配置文件将此认证关闭。

    三 服务器端安全配置选项

     1 PermitRootLogin yes                #允许root的ssh登陆
      2 PubkeyAuthentication yes            #是否使用公钥验证
      3 AuthorizeKeysFile .ssh/authorized_keys        #公钥的保存位置
      4 PasswordAuthentication yes            #允许使用密码验证登陆
      5 PermitEmptyPasswords no                #不允许空密码登陆

    注意:如果开启公钥验证,可以关闭允许root登陆、关闭允许使用密码验证登陆,此时将采用公钥验证登陆,无需输入密码。建议采用此更安全的方式,直接使用私钥和公钥匹配的公钥验证方式。

    四 SSH其他管理

    [root@imxhy]# yum -y install policycoreutils-python
    
    [root@imxhy]# semanage port -a -t ssh_port_t -p tcp 2222
    
    [root@imxhy]# semanage port -l | grep ssh #查看SELinux设置
    
    [root@imxhy]# firewall-cmd --permanent --add-port=2222/tcp
    
    [root@imxhy]# systemctl restart firewalld.service
    
    [root@imxhy]# systemctl restart sshd.service
  • 相关阅读:
    wireshark1
    攻防世界Crypto高手进阶区部分Writeup
    flag_in_your_hand1
    扩展GridView之添加单选列
    C#关于日期月天数和一年有多少周及某年某周时间段的计算
    C# 开发和使用中的32个技巧
    TSQL编程的全局变量
    计算当前月底天数
    存储过程编写经验和优化措施
    ASP.NET 程序中常用的三十三种代码
  • 原文地址:https://www.cnblogs.com/liujunjun/p/12248478.html
Copyright © 2011-2022 走看看