SSH學習之二OpenSSH設定檔解析

來源:互聯網
上載者:User

下面是對SSH設定檔的一些選項的分解說明,ssh_config是OpenSSH用戶端的設定檔,sshd_config是OpenSSH伺服器端的設定檔。

ssh_config的內容如下:


# This is the ssh client system-wide configuration file. See ssh_config(5) for more information. This file provides defaults for users, and the values can be changed in

# er-user configuration files or on the command line.


# Configuration data is parsed as follows: // 配置選項生效的優先順序
# 1. command line options // 命令列選項
# 2. user-specific file // 使用者指定檔案
# 3. system-wide file // 系統範圍的檔案
# Any configuration value is only changed the first time it is set. Thus, host-specific definitions should be at the beginning of the configuration file, and defaults at the end.

# Site-wide defaults for some commonly used options. For a comprehensive list of available options, their meanings and defaults, please see the ssh_config(5) man page.


Host * // 使用的電腦範圍,'*'表示全部
# ForwardAgent no // 設定串連是否經過驗證代理(如果存在)轉寄給遠端電腦
# ForwardX11 no // 設定X11串連是否被自動重新導向到安全的通道和顯示集
# ForwardX11Trusted yes // 是否允許轉寄X11會話
# RhostsRSAAuthentication no // 設定是否使用RSA進行rhosts的安全驗證
# RSAAuthentication yes // 設定是否使用RSA進行安全驗證
# PasswordAuthentication yes // 設定是否需要口令驗證
# HostbasedAuthentication no
# GSSAPIAuthentication no
# GSSAPIDelegateCredentials no
# GSSAPIKeyExchange no
# GSSAPITrustDNS no
# BatchMode no // 如果為yes,則互動輸入口令時的提示(passphrase/password的提示)資訊將被禁止
# CheckHostIP yes // 設定SSH是否查看串連到伺服器的主機的IP地址以防止DNS欺騙。建議設定為yes
# AddressFamily any
# ConnectTimeout 0
# StrictHostKeyChecking ask // 如果設定成yes,SSH就不會自動把電腦的密鑰加入$HOME/.ssh/known_hosts檔案,並且一旦電腦的密匙發生了變化,就拒絕串連
# IdentityFile ~/.ssh/identity
# IdentityFile ~/.ssh/id_rsa // RSA安全驗證檔案的位置
# IdentityFile ~/.ssh/id_dsa // DSA安全驗證檔案的位置
# Port 22 // 伺服器連接埠
# Protocol 2,1 // 使用的SSH協議
# Cipher 3des // 設定加密的方式
# Ciphers aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc
# MACs hmac-md5,hmac-sha1,umac-64@openssh.com,hmac-ripemd160
# EscapeChar ~ // 設定Escape(轉義)字元
# Tunnel no
# TunnelDevice any:any
# PermitLocalCommand no
# VisualHostKey no
# ProxyCommand ssh -q -W %h:%p gateway.example.com
SendEnv LANG LC_* // 局部環境變數
HashKnownHosts yes
GSSAPIAuthentication yes
GSSAPIDelegateCredentials no

sshd_config的內容如下:

# Package generated configuration file See the sshd_config(5) manpage for details

# What ports, IPs and protocols we listen for
Port 22 // sshd的監聽連接埠號碼,預設為22
# Use these options to restrict which interfaces/protocols sshd will bind to
#ListenAddress ::
#ListenAddress 0.0.0.0 // 設定sshd服務綁定的IP地址,0.0.0.0表示偵聽所有地址
Protocol 2 // 預設只使用2.*版本的SSH協議
# HostKeys for protocol version 2
HostKey /etc/ssh/ssh_host_rsa_key // SSH2版本的RSA密鑰存放位置
HostKey /etc/ssh/ssh_host_dsa_key // SSH2版本的DSA密鑰存放位置
HostKey /etc/ssh/ssh_host_ecdsa_key // SSH2版本的ECDSA密鑰存放位置
#Privilege Separation is turned on for security
UsePrivilegeSeparation yes

# Lifetime and size of ephemeral version 1 server key
KeyRegenerationInterval 3600 // 密鑰每隔1小時產生一次
ServerKeyBits 768 // SSH伺服器密鑰的位元

# Logging
SyslogFacility AUTH // 設定sshd發送到syslog所使用的日誌類型
// 設定在記錄來自sshd的訊息時是否給出facility code
LogLevel INFO // syslog記錄層級

# Authentication:
LoginGraceTime 120 // 設定如果使用者不能成功登入,sshd將會在這個配置參數指定的時間過後中斷連線(單位為秒)
PermitRootLogin yes // 如果為yes則允許root使用者使用ssh登入,為no則表示不允許root進行ssh登入
StrictModes yes // 設定sshd在接受登入請求前是否檢查使用者的主目錄以及rhosts檔案的許可權和所有者等資訊。防止目錄和檔案設成任何人都有寫入權限


RSAAuthentication yes // 是否允許RSA驗證
PubkeyAuthentication yes // 是否允許公開金鑰驗證
AuthorizedKeysFile %h/.ssh/authorized_keys// 公開金鑰檔案存放的位置


# Don't read the user's ~/.rhosts and ~/.shosts files
IgnoreRhosts yes // 驗證時是否使用'~/.rhosts'和'~/.shosts'檔案
# For this to work you will also need host keys in /etc/ssh_known_hosts
RhostsRSAAuthentication no // 設定是否允許用rhosts或/etc/hosts.equiv加上RSA進行安全驗證
# similar for protocol version 2
HostbasedAuthentication no
# Uncomment if you don't trust ~/.ssh/known_hosts for RhostsRSAAuthentication
#IgnoreUserKnownHosts yes // 設定sshd在進行RhostsRSAAuthentication安全驗證時是否信任使用者的'~/.ssh/known_hosts'檔案

# To enable empty passwords, change to yes (NOT RECOMMENDED)
PermitEmptyPasswords no // 設定是否允許用空口令登入

# Change to yes to enable challenge-response passwords (beware issues with
# some PAM modules and threads)
ChallengeResponseAuthentication no // 設定是否允許使用提示/應答式認證。sshd支援login.conf檔案中定義的所有認證類型

# Change to no to disable tunnelled clear text passwords
#PasswordAuthentication yes // 設定是否需要口令驗證,預設為yes

# Kerberos options // Kerneros驗證
#KerberosAuthentication no
#KerberosGetAFSToken no
#KerberosOrLocalPasswd yes
#KerberosTicketCleanup yes

# GSSAPI options // GSSAPI 驗證
#GSSAPIAuthentication no
#GSSAPICleanupCredentials yes // 清除驗證資訊

X11Forwarding yes // 設定sshd是否允許X11轉寄,預設為允許
X11DisplayOffset 10
PrintMotd no // 設定sshd是否在使用者登入時顯示/etc/motd中的資訊
PrintLastLog yes // 互動式登入時是否輸出使用者上次登入的日期和時間
TCPKeepAlive yes // TCP活動保持
#UseLogin no // 指定login命令是否可用於互動式登入會話

#MaxStartups 10:30:60
#Banner /etc/issue.net // 設定儲存banner資訊的檔案位置,使用者登入後會顯示該banner資訊

# Allow client to pass locale environment variables
AcceptEnv LANG LC_* // 指定用戶端發送的那些環境變數能後複製到當前會話的運行環境(用戶端需要設定其設定檔ssh_config中的SendEnv參數)

Subsystem sftp /usr/lib/openssh/sftp-server // 用於配置一個外部的服務程式,如檔案傳輸伺服器sftp-server。配置參數的值應該是一個系統名與命令,能夠基於客戶系統的請求開始運行。sftp-server命令實現了sftp檔案傳輸子系統。這個配置參數僅使用與SSH2

# Set this to 'yes' to enable PAM authentication, account processing, and session processing. If this is enabled, PAM authentication will be allowed through the

# ChallengeResponseAuthentication and PasswordAuthentication. Depending on your PAM configuration, PAM authentication via ChallengeResponseAuthentication

# may bypass the setting of "PermitRootLogin without-password". If you just want the PAM account and session checks to run without PAM authentication, then enable

#this but set PasswordAuthentication and ChallengeResponseAuthentication to 'no'.

UsePAM yes // 是否啟用PAM外掛程式式認證模組,預設為yes

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.