【转载】SSH服务器端/etc/ssh/sshd_conf配置文件详解

2023-05-16

[root@u0704-t5-test-shaoew1 ~]$cat /etc/ssh/sshd_config


  1. #Port 22                                          监听端口,默认监听22端口   【默认可修改】
  2. #AddressFamily any                        IPV4和IPV6协议家族用哪个,any表示二者均有
  3. #ListenAddress 0.0.0.0                   指明监控的地址,0.0.0.0表示本机的所有地址  【默认可修改】
  4. #ListenAddress ::                            指明监听的IPV6的所有地址格式
  5. # The default requires explicit activation of protocol 1   
  6. #Protocol 2                                      使用SSH第二版本,centos7默认第一版本已拒绝
  7. # HostKey for protocol version 1      一版的SSH支持以下一种秘钥形式
  8. #HostKey /etc/ssh/ssh_host_key
  9. # HostKeys for protocol version 2                  使用第二版本发送秘钥,支持以下四种秘钥认证的存放位置:(centos6只支持rsa和dsa两种)
  10. HostKey /etc/ssh/ssh_host_rsa_key               rsa私钥认证 【默认】
  11. #HostKey /etc/ssh/ssh_host_dsa_key            dsa私钥认证
  12. HostKey /etc/ssh/ssh_host_ecdsa_key          ecdsa私钥认证
  13. HostKey /etc/ssh/ssh_host_ed25519_key      ed25519私钥认证
  14. # Lifetime and size of ephemeral version 1 server key
  15. #KeyRegenerationInterval 1h
  16. #ServerKeyBits 1024        主机秘钥长度        
  17. # Ciphers and keying      
  18. #RekeyLimit default none
  19. # Logging
  20. # obsoletes QuietMode and FascistLogging
  21. #SyslogFacility AUTH
  22. SyslogFacility AUTHPRIV                   当有人使用ssh登录系统的时候,SSH会记录信息,信息保存在/var/log/secure里面
  23. #LogLevel INFO                                  日志的等级
  24. # Authentication:
  25. #LoginGraceTime 2m                           登录的宽限时间,默认2分钟没有输入密码,则自动断开连接
  26. #PermitRootLogin no
  27. PermitRootLogin yes                            是否允许管理员直接登录,'yes'表示允许
  28. #StrictModes yes                                 是否让sshd去检查用户主目录或相关文件的权限数据
  29. #MaxAuthTries 6                                  最大认证尝试次数,最多可以尝试6次输入密码。之后需要等待某段时间后才能再次输入密码
  30. #MaxSessions 10                                 允许的最大会话数
  31. #RSAAuthentication yes
  32. #PubkeyAuthentication yes
  33. # The default is to check both .ssh/authorized_keys and .ssh/authorized_keys2
  34. # but this is overridden so installations will only check .ssh/authorized_keys
  35. AuthorizedKeysFile .ssh/authorized_keys                 服务器生成一对公私钥之后,会将公钥放到.ssh/authorizd_keys里面,将私钥发给客户端
  36. #AuthorizedPrincipalsFile none 
  37. #AuthorizedKeysCommand none
  38. #AuthorizedKeysCommandUser nobody
  39. # For this to work you will also need host keys in /etc/ssh/ssh_known_hosts
  40. #RhostsRSAAuthentication no
  41. # similar for protocol version 2
  42. #HostbasedAuthentication no
  43. # Change to yes if you don't trust ~/.ssh/known_hosts for
  44. # RhostsRSAAuthentication and HostbasedAuthentication
  45. #IgnoreUserKnownHosts no
  46. # Don't read the user's ~/.rhosts and ~/.shosts files
  47. #IgnoreRhosts yes
  48. # To disable tunneled clear text passwords, change to no here!
  49. #PasswordAuthentication yes
  50. #PermitEmptyPasswords no
  51. PasswordAuthentication yes                    是否允许支持基于口令的认证
  52. # Change to no to disable s/key passwords
  53. #ChallengeResponseAuthentication yes
  54. ChallengeResponseAuthentication no     是否允许任何的密码认证
  55. # Kerberos options                                   是否支持kerberos(基于第三方的认证,如LDAP)认证的方式,默认为no 
  56. #KerberosAuthentication no
  57. #KerberosOrLocalPasswd yes
  58. #KerberosTicketCleanup yes
  59. #KerberosGetAFSToken no
  60. #KerberosUseKuserok yes
  61. # GSSAPI options                                       
  62. GSSAPIAuthentication yes
  63. GSSAPICleanupCredentials no
  64. #GSSAPIStrictAcceptorCheck yes
  65. #GSSAPIKeyExchange no
  66. #GSSAPIEnablek5users no
  67. # Set this to 'yes' to enable PAM authentication, account processing,
  68. # and session processing. If this is enabled, PAM authentication will
  69. # be allowed through the ChallengeResponseAuthentication and
  70. # PasswordAuthentication. Depending on your PAM configuration,
  71. # PAM authentication via ChallengeResponseAuthentication may bypass
  72. # the setting of "PermitRootLogin without-password".
  73. # If you just want the PAM account and session checks to run without
  74. # PAM authentication, then enable this but set PasswordAuthentication
  75. # and ChallengeResponseAuthentication to 'no'.
  76. # WARNING: 'UsePAM no' is not supported in Red Hat Enterprise Linux and may cause several
  77. # problems.
  78. UsePAM yes
  79. #AllowAgentForwarding yes
  80. #AllowTcpForwarding yes
  81. #GatewayPorts no
  82. X11Forwarding yes                    是否允许x11转发,可以让窗口的数据通过SSH连接来传递(请查看ssh -X 参数):#ssh -X  user@IP
  83. #X11DisplayOffset 10
  84. #X11UseLocalhost yes 
  85. #PermitTTY yes
  86. #PrintMotd yes
  87. #PrintLastLog yes
  88. #TCPKeepAlive yes
  89. #UseLogin no
  90. UsePrivilegeSeparation sandbox # Default for new installations.
  91. #PermitUserEnvironment no
  92. #Compression delayed
  93. #ClientAliveInterval 0
  94. #ClientAliveCountMax 3
  95. #ShowPatchLevel no
  96. #UseDNS yes              是否反解DNS,如果想让客户端连接服务器端快一些,这个可以改为no
  97. #PidFile /var/run/sshd.pid
  98. #MaxStartups 10:30:100
  99. #PermitTunnel no
  100. #ChrootDirectory none
  101. #VersionAddendum none
  102. # no default banner path
  103. #Banner none
  104. # Accept locale-related environment variables
  105. AcceptEnv LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES
  106. AcceptEnv LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT
  107. AcceptEnv LC_IDENTIFICATION LC_ALL LANGUAGE
  108. AcceptEnv XMODIFIERS
  109. # override default of no subsystems
  110. Subsystem sftp /usr/libexec/openssh/sftp-server                    支持 SFTP ,如果注释掉,则不支持sftp连接
  111. # Example of overriding settings on a per-user basis
  112. #Match User anoncvs
  113. # X11Forwarding no
  114. # AllowTcpForwarding no
  115. # PermitTTY no
  116. # ForceCommand cvs server
  117. AllowUsers user1 user2                登录白名单(默认没有这个配置,需要自己手动添加),允许远程登录的用户。如果名单中没有的用户,则提示拒绝登录

 

【原文】https://www.cnblogs.com/shaoerwei/articles/7594879.html

转载于:https://www.cnblogs.com/freess/p/10014812.html

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

【转载】SSH服务器端/etc/ssh/sshd_conf配置文件详解 的相关文章

  • 将私钥作为字符串的 Java SFTP 客户端

    Apache Commons 和 JSch 都需要私钥文件来建立 SFTP 连接 我正在从事的项目将用于连接到多个 SFTP 服务器 因此 我们不希望部署多个私钥文件 而是将这些密钥作为字符串保存在加密的配置文件中 是否有不需要私钥文件对象
  • 是否可以在远程 ssh 命令中使用变量?

    我想在远程计算机上按顺序执行多个命令 并且后面的一些命令依赖于前面的命令 在最简单的例子中 我得到了这个 ssh my server echo this is my server abc 2 this is my server abc 2
  • python使用ssh时找不到模块

    我在服务器上使用 python 当我运行需要 numpy 模块的 python 命令时 如果我这样做 ssh
  • 无法将主机添加到已知主机列表,如何调试[关闭]

    Closed 这个问题不符合堆栈溢出指南 help closed questions 目前不接受答案 尝试使用 v 进行 ssh 输出是 ccc es chen ssh cccadmin ccchost A X v OpenSSH 5 9p
  • SSH 连接超时

    我正在尝试使用以下命令建立 SSH 连接golang org x crypto ssh我有点惊讶我似乎不知道如何超时NewSession函数 实际上我没有看到任何超时的方法 当我尝试连接到有问题的服务器时 它会挂起很长时间 我写了一些可以使
  • 使用 SSH 从 BitBucket pip 安装自定义包,无需在 Docker 构建期间输入 SSH 密码

    我正在尝试 pip 安装 通过conda env create命令 来自 BitBucket 的自定义 python 包docker build命令 无需输入 SSH 密码 密码 这个问题类似于这另一个问题 https stackoverf
  • 如何根据本地子网自动切换ssh配置?

    当我在某个网络 子网为 10 10 11 x 上时 我需要跳过中间主机才能到达目的地 因为我无法更改目的地端口 并且可以退出受限网络的端口有限 我成功地使用了如下所示的 ssh 配置 Host web direct web HostName
  • 使用 bash 通过 ssh 启动进程,然后在 sigint 上终止它

    我想使用 ssh 在不同的机器上启动几个作业 如果用户随后中断主脚本 我想优雅地关闭所有作业 这是我正在尝试做的事情的一个简短示例 bin bash trap aborted SIGINT SIGTERM aborted kill SIGT
  • 通过 Paramiko SSH 的 SQLAlchemy

    我的服务器上有一个数据库 我需要通过 SSH 访问该数据库 现在我通过使用命令行来获取数据来处理数据库 import paramiko ssh paramiko SSHClient ssh set missing host key poli
  • 将公钥添加到 ~/.ssh/authorized_keys 不会自动登录

    我将公共 SSH 密钥添加到授权密钥 file ssh localhost应该让我登录而不询问密码 我这样做并尝试输入ssh localhost 但它仍然要求我输入密码 我还需要进行其他设置才能使其正常工作吗 我已按照更改权限的说明进行操作
  • 如何在 AWS 上设置无密码 ssh

    如何在 AWS 集群上的节点之间设置无密码 ssh 以下设置无密码身份验证的步骤已针对 Centos 和 Ubuntu 进行了彻底测试 假设 您已经可以访问您的 EC2 机器 可能正在使用 pem 密钥 或者您拥有具有 root 权限的 u
  • 用于搜索内部文件的 ssh 命令

    几周前 我的两个网站可能被 ftp 暴力攻击所利用 破坏了我网站的许多文件 我发现他们通常会在js或php文件中插入以下代码 Trojan code removed as irrelevant to this question 我想通过 s
  • 我可以在远程服务器上运行位于本地计算机上的 bash 脚本吗?

    我有本地脚本 我想在远程服务器上运行 我已经设置了 ssh 密钥对以启用无需密码的登录 我当前的方法是将脚本 rsync 到服务器 然后运行它 ssh user remoteserver rsync localserver script s
  • 如何在接收端打开没有 SSHD 的 shell?

    我有一台没有 SSHD 的机器 我想从远程机器 我可以完全控制 在这台机器上打开 bash shell 由于我的有限机器上有 SSH 因此我配置了反向代理 ssh R 19999 localhost 22 remoteuser remote
  • 为什么 ssh-agent 需要 root 访问权限?

    我刚刚安装了 Archbang 并尝试克隆我的 Git 项目 这需要 SSH 密钥 过去 我在 Ubuntu 和 RedHat 机器上遵循 Github 指南取得了成功 但由于某种原因 它在我的新 Arch 安装上不起作用 我已使用以下命令
  • 健全性检查 SSH 公钥? [关闭]

    Closed 这个问题是无关 help closed questions 目前不接受答案 我已要求用户提供他们的公共 id rsa pub ssh 密钥 然后将其放入 home theiraccount ssh authorized key
  • 使用 Jenkins Git 插件中的 SSH 密钥在构建期间运行 Git 命令

    我们在 Jenkins 上的构建作业作为发布构建的一部分运行一些 git 命令 例如 git push 和 git pull 因此需要一种在构建期间从 shell 运行经过身份验证的 git 命令的方法 我们的詹金斯奴隶不持有任何凭证 因为
  • 如何在 Python Paramiko 中配置 ssh StrictHostKeyChecking=no 的等效项

    我正在使用 Paramiko 通过 Python 脚本进行 sshing 我的ssh命令如下 ssh A o strictHostKeyChecking no
  • 无法通过 SSH 连接到 EC2 实例

    因此 我从网上启动了我的实例 下载了密钥对并安装了它 大约一天的时间里一切都运行良好 然后我重新启动了计算机 但我无法再通过 SSH 连接到它 我尝试重新下载密钥对并重新安装它 但我不断收到 权限被拒绝 公钥 错误 这是详细的输出 我也尝试
  • 如何在两个不同帐户之间设置无密码身份验证

    我们可以在两台机器的两种不同用途之间设置无密码身份验证吗 例如 计算机A有用户A 计算机B有用户B 我们可以设置密码 ssh 以便计算机 A 上的用户 A 使用其用户帐户 A 登录计算机 B 谢谢你 如果我理解你的问题 你能设置一下吗ssh

随机推荐