SSH(ArchLinux) 的简单配置

来源:互联网 发布:办公软件基本教程 编辑:程序博客网 时间:2024/05/22 15:28

安装ssh

pacman -S openssh

 

配置ssh

 

配置文件 /etc/ssh/ssh_config 

  1. #   $OpenBSD: sshd_config,v 1.75 2007/03/19 01:01:29 djm Exp $
  2. # This is the ssh client system-wide configuration file.  See
  3. # ssh_config(5) for more information.  This file provides defaults for
  4. # users, and the values can be changed in per-user configuration files
  5. # or on the command line.
  6. # Configuration data is parsed as follows:
  7. #  1. command line options
  8. #  2. user-specific file
  9. #  3. system-wide file
  10. # Any configuration value is only changed the first time it is set.
  11. # Thus, host-specific definitions should be at the beginning of the
  12. # configuration file, and defaults at the end.
  13. # Site-wide defaults for various options
  14. # Host *
  15. #   ForwardAgent no
  16. #   ForwardX11 no
  17. #   RhostsRSAAuthentication no
  18. #   RSAAuthentication yes
  19. #   PasswordAuthentication yes
  20. #   HostbasedAuthentication no
  21. #   BatchMode no
  22. #   CheckHostIP yes
  23. #   AddressFamily any
  24. #   ConnectTimeout 0
  25. #   StrictHostKeyChecking ask
  26. #   IdentityFile ~/.ssh/identity
  27. #   IdentityFile ~/.ssh/id_rsa
  28. #   IdentityFile ~/.ssh/id_dsa
  29. #   Port 22
  30. #   Protocol 2,1
  31. #   Cipher 3des
  32. #   Ciphers aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,arcfour,aes192-cbc,aes256-cbc
  33. #   EscapeChar ~

 /etc/ssh/sshd_config

  1. #   $OpenBSD: sshd_config,v 1.75 2007/03/19 01:01:29 djm Exp $
  2. # This is the sshd server system-wide configuration file.  See
  3. # sshd_config(5) for more information.
  4. # This sshd was compiled with PATH=/usr/bin:/bin:/usr/sbin:/sbin
  5. # The strategy used for options in the default sshd_config shipped with
  6. # OpenSSH is to specify options with their default value where
  7. # possible, but leave them commented.  Uncommented options change a
  8. # default value.
  9. #Port 22
  10. #Protocol 2,1
  11. ListenAddress 0.0.0.0
  12. #ListenAddress ::
  13. # HostKey for protocol version 1
  14. #HostKey /etc/ssh/ssh''host''key
  15. # HostKeys for protocol version 2
  16. #HostKey /etc/ssh/ssh''host''rsa_key
  17. #HostKey /etc/ssh/ssh''host''dsa_key
  18. # Lifetime and size of ephemeral version 1 server key
  19. #KeyRegenerationInterval 1h
  20. #ServerKeyBits 768
  21. # Logging
  22. #obsoletes ~QuietMode and ~FascistLogging
  23. #SyslogFacility AUTH
  24. #LogLevel INFO
  25. # Authentication:
  26. #LoginGraceTime 2m
  27. #PermitRootLogin yes
  28. #StrictModes yes
  29. #MaxAuthTries 6
  30. #RSAAuthentication yes
  31. #PubkeyAuthentication yes
  32. #AuthorizedKeysFile     .ssh/authorized_keys
  33. # For this to work you will also need host keys in /etc/ssh/ssh''known''hosts
  34. #RhostsRSAAuthentication no
  35. # similar for protocol version 2
  36. #HostbasedAuthentication no
  37. # Change to yes if you don't trust ~/.ssh/known_hosts for
  38. # RhostsRSAAuthentication and HostbasedAuthentication
  39. #IgnoreUserKnownHosts no
  40. # Don't read the user's ~/.rhosts and ~/.shosts files
  41. #IgnoreRhosts yes
  42. # To disable tunneled clear text passwords, change to no here!
  43. #PasswordAuthentication yes
  44. #PermitEmptyPasswords no
  45. # Change to no to disable s/key passwords
  46. #ChallengeResponseAuthentication yes
  47. # Kerberos options
  48. #KerberosAuthentication no
  49. #KerberosOrLocalPasswd yes
  50. #KerberosTicketCleanup yes
  51. #KerberosGetAFSToken no
  52. # GSSAPI options
  53. #GSSAPIAuthentication no
  54. #GSSAPICleanupCredentials yes
  55. # Set this to 'yes' to enable PAM authentication, account processing,
  56. # and session processing. If this is enabled, PAM authentication will
  57. # be allowed through the ~ChallengeResponseAuthentication mechanism.
  58. # Depending on your PAM configuration, this may bypass the setting of
  59. # PasswordAuthentication, ~PermitEmptyPasswords, and
  60. # "PermitRootLogin without-password". If you just want the PAM account and
  61. # session checks to run without PAM authentication, then enable this but set
  62. ChallengeResponseAuthentication=no
  63. #UsePAM no
  64. #AllowTcpForwarding yes
  65. #GatewayPorts no
  66. #X11Forwarding no
  67. #X11DisplayOffset 10
  68. #X11UseLocalhost yes
  69. #PrintMotd yes
  70. #PrintLastLog yes
  71. #TCPKeepAlive yes
  72. #UseLogin no
  73. #UsePrivilegeSeparation yes
  74. #PermitUserEnvironment no
  75. #Compression yes
  76. #ClientAliveInterval 0
  77. #ClientAliveCountMax 3
  78. #UseDNS yes
  79. #PidFile /var/run/sshd.pid
  80. #MaxStartups 10
  81. # no default banner path
  82. #Banner /some/path
  83. # override default of no subsystems
  84. Subsystem       sftp    /usr/lib/ssh/sftp-server

然后配置 /etc/hosts.allow

  1. ssh:ALL  //没这个的话,会有很多错误。"Server unexpectedly closed network connection"

启动sshd

  1. /etc/rc.d/sshd restart

开机自动开启sshd

  1. DAEMONS=(... ... ... ... ... sshd ... ... ...)
原创粉丝点击