Restrict users from using ssh keys for authentication and login

Source: Internet
Author: User
For the sake of server and user security, the user password authentication method is prohibited, and the key-based method is used. Lastlogin: FriOct1214: 14: 012012from192.168.7.251root@Cacti.Nagios: [root] vietcsshsshd_config # $ OpenBSD: sshd_config, v1.802008070202: 24: 18 djmExp $ # Thisisthesshdse

For the sake of server and user security, the user password authentication method is prohibited, and the key-based method is used. Lastlogin: FriOct1214: 14: example. 168.7.small root@Cacti.Nagios: [/root] vi/etc/ssh/sshd_config # $ OpenBSD: sshd_config, v1.802008/07/0202: 24: 18 djmExp $ # Thisisthesshdse

For servers andUserIs not allowed.UserPasswordAuthenticationThe "key" method.

 
 
  1. Last login: Fri Oct 12 14:14:01 2012 from 192.168.7.20.
  2. Root@Cacti.Nagios: [/root] vi/etc/ssh/sshd_config
  3. # $ OpenBSD: sshd_config, v 1.80 2008/07/02 02:24:18 djm Exp $
  4. # This is the sshd server system-wide configuration file. See
  5. # Sshd_config (5) for more information.
  6. # This sshd was compiled with PATH =/usr/local/bin:/usr/bin
  7. # The strategy used for options in the default sshd_config shipped
  8. # OpenSSH is to specify options with their default value where
  9. # Possible, but leave them commented. Uncommented options change
  10. # Default value.
  11. # Port 22
  12. # AddressFamily any
  13. # ListenAddress 0.0.0.0
  14. # ListenAddress ::
  15. # Disable legacy (protocol version 1) support in the server for new
  16. # Installations. In future the default will change to require explicit
  17. # Activation of protocol 1
  18. Protocol 2The listener is changed to this status after modification. Only SSH2 is used.
  19. # HostKey for protocol version 1
  20. # HostKey/etc/ssh/ssh_host_key
  21. # HostKeys for protocol version 2
  22. # HostKey/etc/ssh/ssh_host_rsa_key
  23. # HostKey/etc/ssh/ssh_host_dsa_key
  24. # Lifetime and size of ephemeral version 1 server key
  25. # KeyRegenerationInterval 1 h
  26. # ServerKeyBits 1024
  27. # Logging
  28. # Obsoletes QuietMode and FascistLogging
  29. # SyslogFacility AUTH
  30. SyslogFacility AUTHPRIV
  31. # LogLevel INFO
  32. # Authentication:
  33. # LoginGraceTime 2 m
  34. # PermitRootLogin yes
  35. PermitRootLogin noThe supervisor is changed to this status after modification, and root is not allowed.ProceedLogin
  36. # StrictModes yes
  37. # MaxAuthTries 6
  38. # MaxSessions 10
  39. # RSAAuthentication yes
  40. # PubkeyAuthentication yes
  41. # AuthorizedKeysFile. ssh/authorized_keys
  42. # AuthorizedKeysCommand none
  43. # AuthorizedKeysCommandRunAs nobody
  44. # For this to work you will also need host keys in/etc/ssh/ssh_known_hosts
  45. # RhostsRSAAuthentication no
  46. # Similar for protocol version 2
  47. # HostbasedAuthentication no
  48. # Change to yes if you don't trust ~ /. Ssh/known_hosts
  49. # RhostsRSAAuthentication and HostbasedAuthentication
  50. # IgnoreUserKnownHosts no
  51. # Don't read the user's ~ /. Rhosts and ~ /. Shosts files
  52. # IgnoreRhosts yes
  53. # To disable tunneled clear text passwords, change to no here!
  54. # PasswordAuthentication yes
  55. PasswordAuthentication noThe token is changed to this status after modification. logon using a password is not allowed.
  56. # PermitEmptyPasswords no
  57. PermitEmptyPasswords noReset changes to this status. Do not enter a password.ProceedLogin
  58. "/Etc/ssh/sshd_config" 141L, 3941C written
  59. Root@Cacti.Nagios: [/root] vi/etc/hosts. deny shield modify blocking rules and add lines at the end of the text
  60. #
  61. # Hosts. deny This file contains access rules which are used
  62. # Deny connections to network services that either use
  63. # The tcp_wrappers library or that have been
  64. # Started through a tcp_wrappers-enabled xinetd.
  65. #
  66. # The rules in this file can also be set up in
  67. #/Etc/hosts. allow with a 'deny' option instead.
  68. #
  69. # See 'man 5 hosts_options 'and 'man 5 hosts_access'
  70. # For information on rule syntax.
  71. # See 'man tcpd' for information on tcp_wrappers
  72. #
  73. Sshd: ALL clients add this line to shield all ssh connection requests.
  74. "/Etc/hosts. deny" 14L, 469C written
  75. You have new mail in/var/spool/mail/root
  76. Root@Cacti.Nagios: [/root] vi/etc/hosts. allow modify allow rules to add lines at the end of the text
  77. #
  78. # Hosts. allow This file contains access rules which are used
  79. # Allow or deny connections to network services that
  80. # Either use the tcp_wrappers library or that have been
  81. # Started through a tcp_wrappers-enabled xinetd.
  82. #
  83. # See 'man 5 hosts_options 'and 'man 5 hosts_access'
  84. # For information on rule syntax.
  85. # See 'man tcpd' for information on tcp_wrappers
  86. #
  87. Sshd: 192.168.7. Only 192.168.7 is allowed. Network Segment machine sshLogin
  88. ~
  89. ~
  90. ~
  91. "/Etc/hosts. allow" 11L, Objective C written
  92. Root@Cacti.Nagios: [/root] su-admin
  93. Admin@Cacti.Nagios: [/data] ssh-keygen-t rsa
  94. Generating public/private rsa key pair.
  95. Enter file in which to save the key (/data/. ssh/id_rsa ):
  96. Created directory '/data/. ssh '.
  97. Enter passphrase (empty for no passphrase ):
  98. Enter same passphrase again:
  99. Your identification has been saved in/data/. ssh/id_rsa.
  100. Your public key has been saved in/data/. ssh/id_rsa.pub.
  101. The key fingerprint is:
  102. E5: 15: ba: be: 59: ef: 2e: 74: df: b6: ee: e1: 6a: 24: be: da admin@Cacti.Nagios
  103. The key's randomart image is:
  104. + -- [RSA 2048] ---- +
  105. |. |
  106. |... |
  107. | O. |
  108. | O |
  109. | S o |
  110. | ...... |
  111. | O. +. o. |
  112. |. =. O. = |
  113. |. + Eo = B *. |
  114. + ----------------- +
  115. Admin@Cacti.Nagios: [/data] ls-
  116. ... Bash_history. bash_logout. bash_profile. bashrc lost + found. ssh. viminfo
  117. Admin@Cacti.Nagios: [/data] cd. ssh/
  118. Admin@Cacti.Nagios: [/data/. ssh] ll
  119. Total 8
  120. -Rw ------- 1 admin 1751 Oct 12 id_rsa
  121. -Rw-r -- 1 admin 401 Oct 12 id_rsa.pub
  122. Admin@Cacti.Nagios: [/data/. ssh] cat ~ /. Ssh/id_rsa.pub> ~ /. Ssh/authorized_keys
  123. Admin@Cacti.Nagios: [/data/. ssh] ls-
  124. ... Authorized_keys id_rsa id_rsa.pub
  125. Admin@Cacti.Nagios: [/data/. ssh] chmod 400 authorized_keys
  126. Admin@Cacti.Nagios: [/data/. ssh] ll-
  127. Total 20
  128. Drwx ------ 2 admin 4096 Oct 12.
  129. Drwxr-xr-x 4 admin 4096 Oct 12 ..
  130. -R -------- 1 admin 401 Oct 12 authorized_keys
  131. -Rw ------- 1 admin 1751 Oct 12 id_rsa
  132. -Rw-r -- 1 admin 401 Oct 12 id_rsa.pub
  133. Now, the private key id_rsa is exported to the windows client. Then, delete the generated public key id_rsa.pub.
  134. Restart the sshd service to make the configuration changes take effect.
  135. Root@Cacti.Nagios: [/root]/etc/rc. d/init. d/sshd restart Stopping sshd: [OK] Starting sshd: [OK]

650) this. width = 650; "src =" http://cdn.verydemo.com/upload/2013_05_29/13698145869140.jpg "border =" 0 "alt =" "/> 650) this. width = 650; "src =" http://cdn.verydemo.com/upload/2013_05_29/13698145872331.jpg "border =" 0 "alt =" "/> 650) this. width = 650; "src =" http://cdn.verydemo.com/upload/2013_05_29/13698145875642.jpg "border =" 0 "alt =" "/> 650) this. width = 650; "src =" http://cdn.verydemo.com/upload/2013_05_29/13698145878883.jpg "border =" 0 "alt =" "/>

Bug blog

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.