man ssh翻譯(ssh命令中文手冊)



本文為命令ssh的man文檔翻譯,翻譯了90%的內容,剩余是一些沒必要翻譯的東西,請見諒。

如此文有所疑惑,希望我的另一篇文章能解惑:http://www.cnblogs.com/f-ck-need-u/p/7129122.html

本人譯作集合:http://www.cnblogs.com/f-ck-need-u/p/7048359.html


 

SSH(1)                    BSD General Commands Manual                   SSH(1)

 

NAME

     ssh -- OpenSSH SSH 客戶端工具(遠程登錄程序)

 

SYNOPSIS

     ssh [-1246AaCfGgKkMNnqsTtVvXxYy] [-b bind_address] [-c cipher_spec]

         [-D [bind_address:]port] [-E log_file] [-e escape_char]

         [-F configfile] [-I pkcs11] [-i identity_file] [-L address]

         [-l login_name] [-m mac_spec] [-O ctl_cmd] [-o option] [-p port]

         [-Q query_option] [-R address] [-S ctl_path] [-W host:port]

         [-w local_tun[:remote_tun]] [user@]hostname [command]

 

DESCRIPTION

     ssh(SSH客戶端)是一個登陸遠程主機和在遠程主機上執行命令的程序。它的目

     的是在不安全的網絡中為兩個互不信任的主機提供安全加密的通信方式。也

     可以通過安全隧道被轉發X11連接、任意TCP端口和UNIX套接字上的數據包。

     ssh連接並登錄指定的主機(還可以指定用戶名)。客戶端必須提供身份標識給

     遠程主機,提供方式有多種,見下文。

     如果ssh命令行中指定了命令,則將在遠程主機上執行而不是登錄遠程主機。

   

     選項說明如下:

     -1      強制使用ssh v1版本。

     -2      強制使用ssh v2版本。

     -4      強制只使用IPv4地址。

     -6      強制只使用IPv6地址。

     -A      啟用代理轉發功能,也可在全局配置文件(/etc/ssh/ssh_config)中配置。

             代理轉發功能應該要謹慎開啟。

     -a      禁用代理轉發功能。

     -b bind_address 

             在本地主機上綁定用於ssh連接的地址,當系統有多個ip時才生效。

     -C      請求會話間的數據壓縮傳遞。對於網絡緩慢的主機,壓縮對連接有所

             提升。但對網絡流暢的主機來說,壓縮只會更糟糕。

     -c      選擇ssh會話間數據加密算法。

     -D [bind_address:]port

      指定一個本地動態應用層端口做轉發端口。工作方式是分配一個套接
      字監聽在此端口,當監聽到此端口有連接時,此連接中的數據將通過
      安全隧道轉發到server端,server端再和目的地(端口)建立連接,目
      的地(端口)由應用層協議決定。目前支SOCK4和SOCK5兩種協議,並且
      SSH將扮演SOCKS服務端角色。

             只有root用戶可以開啟特權端口。動態轉發端口也可以在配置文件

             中指定。

             默認情況下,轉發端口將綁定在GatewayPorts指令指定的地址上,但

             是可以顯式指定bind_address,如果bind_address設置為"localhost",

             則轉發端口將綁定在回環地址上,如果bind_address不設置或設置為

             "*",則轉發端口綁定在所有網路接口上。

     -E log_file

             將debug日志寫入到log_file中,而不是默認的標准錯誤輸出stderr。

     -e escape_char

             設置逃逸首字符,默認為"~",設置為"none"將禁用逃逸字符,並使

             得會話完全透明。詳細用法見后文。

     -F configfile

             指定用戶配置文件,默認為~/.ssh/config,如果在命令行指定了該

             選項,則全局配置文件/etc/ssh_config將被忽略。

     -f      請求ssh在工作在后台模式。該選項隱含了"-n"選項,所以標准輸入

             將變為/dev/null。

     -G      使用該選項將使得ssh在匹配完Host后將輸出與之對應的配置選項,

             然后退出

     -g      允許遠程主機連接到本地轉發端口上。

     -I pkcs11

             Specify the PKCS#11 shared library ssh should use to communicate

             with a PKCS#11 token providing the user's private RSA key.

     -i identity_file 

             指定公鑰認證時要讀取的私鑰文件。默認為~/.ssh/id_rsa。

     -K      啟用GSSAPI認證並將GSSAPI憑據轉發(分派)到服務端。

     -k      禁止轉發(分派)GSSAPI憑據到服務端。

     -L [bind_address:]port:host:hostport

     -L [bind_address:]port:remote_socket

     -L local_socket:host:hostport

     -L local_socket:remote_socket

      對本地指定的TCP端口port的連接都將轉發到指定的遠程主機及其端
      口上(host:hostport)。工作方式是在本地端分配一個socket監聽TCP
      端口。當監聽到本地此端口有連接時,連接將通過安全隧道轉發給
      遠程主機(server),然后從遠程主機(是server端)上建立一個到
      host:hostport的連接,完成數據轉發。

      譯者注:隧道建立在本地和遠程主機(server端,即中間主機)之間,
      而非本地和host之間,也不是遠程主機和host之間。

             端口轉發也可以在配置文件中指定。只有root用戶才能轉發特權端口

             (小於1024)。

             默認本地端口被綁定在GatewayPorts指令指定的地址上。但是,顯式

             指定的bind_address可以用於綁定連接到指定的地址上。如果設置

             bind_address為"localhost",則表示被綁定的監聽端口只可用於本地

             連接(即該端口監聽在回環地址上),如果不設置bind_address或設置

             為"*"則表示綁定的端口可用於所有網絡接口上的連接(即表示該端口

             監聽在所有地址上)。

     -l login_name

             指定登錄在遠程機器上的用戶名。這也可以在全局配置文件中設置。

     -M      將ssh客戶端置入"master"模式,以便連接共享(連接復用)。

             即實現ControlMaster和ControlPersist的相關功能。

     -m mac_spec

             A comma-separated list of MAC (message authentication code)

             algorithms, specified in order of preference.  See the MACs key‐

             word for more information. 

     -N      明確表示不執行遠程命令。僅作端口轉發時比較有用。 

     -n      將/dev/null作為標准輸入stdin,可以防止從標准輸入中讀取內容。

             當ssh在后台運行時必須使用該項。但當ssh被詢問輸入密碼時失效。

     -O ctl_cmd

             Control an active connection multiplexing master process.  When

             the -O option is specified, the ctl_cmd argument is interpreted

             and passed to the master process.  Valid commands are: “check”

             (check that the master process is running), “forward” (request

             forwardings without command execution), “cancel” (cancel for‐

             wardings), “exit” (request the master to exit), and “stop”

             (request the master to stop accepting further multiplexing

             requests).

     -o option

             Can be used to give options in the format used in the configura‐

             tion file.  This is useful for specifying options for which there

             is no separate command-line flag.  For full details of the

             options listed below, and their possible values, see

             ssh_config(5).

                   AddKeysToAgent

                   AddressFamily

                   BatchMode

                   BindAddress

                   CanonicalDomains

                   CanonicalizeFallbackLocal

                   CanonicalizeHostname

                   CanonicalizeMaxDots

                   CanonicalizePermittedCNAMEs

                   CertificateFile

                   ChallengeResponseAuthentication

                   CheckHostIP

                   Cipher

                   Ciphers

                   ClearAllForwardings

                   Compression

                   CompressionLevel

                   ConnectionAttempts

                   ConnectTimeout

                   ControlMaster

                   ControlPath

                   ControlPersist

                   DynamicForward

                   EscapeChar

                   ExitOnForwardFailure

                   FingerprintHash

                   ForwardAgent

                   ForwardX11

                   ForwardX11Timeout

                   ForwardX11Trusted

                   GatewayPorts

                   GlobalKnownHostsFile

                   GSSAPIAuthentication

                   GSSAPIDelegateCredentials

                   HashKnownHosts

                   Host

                   HostbasedAuthentication

                   HostbasedKeyTypes

                   HostKeyAlgorithms

                   HostKeyAlias

                   HostName

                   IdentityFile

                   IdentitiesOnly

                   IPQoS

                   KbdInteractiveAuthentication

                   KbdInteractiveDevices

                   KexAlgorithms

                   LocalCommand

                   LocalForward

                   LogLevel

                   MACs

                   Match

                   NoHostAuthenticationForLocalhost

                   NumberOfPasswordPrompts

                   PasswordAuthentication

                   PermitLocalCommand

                   PKCS11Provider

                   Port

                   PreferredAuthentications

                   Protocol

                   ProxyCommand

                   ProxyUseFdpass

                   PubkeyAcceptedKeyTypes

                   PubkeyAuthentication

                   RekeyLimit

                   RemoteForward

                   RequestTTY

                   RhostsRSAAuthentication

                   RSAAuthentication

                   SendEnv

                   ServerAliveInterval

                   ServerAliveCountMax

                   StreamLocalBindMask

                   StreamLocalBindUnlink

                   StrictHostKeyChecking

                   TCPKeepAlive

                   Tunnel

                   TunnelDevice

                   UpdateHostKeys

                   UsePrivilegedPort

                   User

                   UserKnownHostsFile

                   VerifyHostKeyDNS

                   VisualHostKey

                   XAuthLocation

     -p port

             指定要連接遠程主機上哪個端口,也可在全局配置文件中指定。

     -Q query_option

             Queries ssh for the algorithms supported for the specified ver‐

             sion 2.  The available features are: cipher (supported symmetric

             ciphers), cipher-auth (supported symmetric ciphers that support

             authenticated encryption), mac (supported message integrity

             codes), kex (key exchange algorithms), key (key types), key-cert

             (certificate key types), key-plain (non-certificate key types),

             and protocol-version (supported SSH protocol versions).

     -q      靜默模式。大多數警告信息將不輸出。

     -R [bind_address:]port:host:hostport

     -R [bind_address:]port:local_socket

     -R remote_socket:host:hostport

     -R remote_socket:local_socket

             對遠程(server端)指定的TCP端口port的連接都就將轉發到本地主機和

             端口上,工作方式是在遠端(server)分配一個套接字socket監聽TCP端

             口。當監聽到此端口有連接時,連接將通過安全隧道轉發給本地,然后

            從本地主機建一條到host:hostport的連接。

             端口轉發也可以在配置文件中指定。只有root用戶才能轉發特權端口

             (小於1024)。

             默認遠程(server)套接字被綁定在回環地址上。但是,顯式指定的

             bind_address可以用於綁定套接字到指定的地址上。如果不設置

             bind_address或設置為"*"則表示套接字監聽在所有網絡接口上。

             只有當遠程(server)主機的GatewayPorts選項開啟時,指定的

             bind_address才能生效。(見sshd_config(5))。

             如果port值為0,遠程主機(server)監聽的端口將被動態分配,並且在

             運行時報告給客戶端。

     -S ctl_path

             Specifies the location of a control socket for connection shar‐

             ing, or the string “none” to disable connection sharing.  Refer

             to the description of ControlPath and ControlMaster in

             ssh_config(5) for details.

     -s      請求在遠程主機上調用一個子系統(subsystem)。子系統有助於ssh為

              其他程序(如sftp)提供安全傳輸。子系統由遠程命令指定。

     -T      禁止為ssh分配偽終端。

     -t       強制分配偽終端,重復使用該選項"-tt"將進一步強制。

     -V      顯示版本號並退出。

     -v      詳細模式,將輸出debug消息,可用於調試。"-vvv"可更詳細。

     -W host:port

             請求客戶端上的標准輸入和輸出通過安全隧道轉發到host:port上,該選

             項隱含了"-N","-T",ExitOnForwardFailure和ClearAllForwardings選項。

     -w local_tun[:remote_tun]

             Requests tunnel device forwarding with the specified tun(4)

             devices between the client (local_tun) and the server

             (remote_tun).

             The devices may be specified by numerical ID or the keyword

             “any”, which uses the next available tunnel device.  If

             remote_tun is not specified, it defaults to “any”.  See also

             the Tunnel and TunnelDevice directives in ssh_config(5).  If the

             Tunnel directive is unset, it is set to the default tunnel mode,

             which is “point-to-point”.

     -X      Enables X11 forwarding.  This can also be specified on a per-host

             basis in a configuration file.

             X11 forwarding should be enabled with caution.  Users with the

             ability to bypass file permissions on the remote host (for the

             user's X authorization database) can access the local X11 display

             through the forwarded connection.  An attacker may then be able

             to perform activities such as keystroke monitoring.

             For this reason, X11 forwarding is subjected to X11 SECURITY

             extension restrictions by default.  Please refer to the ssh -Y

             option and the ForwardX11Trusted directive in ssh_config(5) for

             more information.            

     -x      Disables X11 forwarding.

     -Y      Enables trusted X11 forwarding.  Trusted X11 forwardings are not

             subjected to the X11 SECURITY extension controls.

     -y      使用syslog發送日志信息。默認情況下日志信息發送到標准錯誤輸出

 

     除了從命令行獲取配置信息,還可以從用戶配置文件和全局配置文件中

     獲取額外配置信息。詳細信息見ssh_config(5)

 

認證機制

     可用的認證機制及它們的先后順序為:GSSAPI-based,host-based,public key,

     challenge-response,password。PreferredAuthentications選項可以改變默認的認證順序

         

     Host-based authentication works as follows: If the machine the user logs

     in from is listed in /etc/hosts.equiv or /etc/shosts.equiv on the remote

     machine, and the user names are the same on both sides, or if the files

     ~/.rhosts or ~/.shosts exist in the user's home directory on the remote

     machine and contain a line containing the name of the client machine and

     the name of the user on that machine, the user is considered for login.

     Additionally, the server must be able to verify the client's host key

     (see the description of /etc/ssh_known_hosts and ~/.ssh/known_hosts,

     below) for login to be permitted.  This authentication method closes

     security holes due to IP spoofing, DNS spoofing, and routing spoofing.

     [Note to the administrator: /etc/hosts.equiv, ~/.rhosts, and the

     rlogin/rsh protocol in general, are inherently insecure and should be

     disabled if security is desired.]

 

     公鑰認證機制:用戶創建公鑰/私鑰密鑰對,將公鑰發送給服務端,所以服務端

     知道的是公鑰,私鑰只有自己知道。   

 

     ~/.ssh/authorized_keys文件列出了允許登錄的公鑰。當發起連接時,ssh客戶端程序

     告訴服務端程序要使用哪個密鑰對來完成身份驗證,並告訴服務端自己已經訪問過

     私鑰部分(譯者注:不能直接提供私鑰給服務端進行比對監測,因為私鑰不能泄露),

     然后服務端則檢查對應的公鑰部分以確定是否要接受該客戶端的連接。

 

     用戶使用ssh-keygen創建密鑰對(以rsa算法為例),將保存在~/.ssh/id_rsa和~/.ssh/id_rsa.pub。

     然后該用戶拷貝公鑰文件到遠程主機上某用戶(如A)家目錄下的~/.ssh/authorized_keys,

     之后用戶就可以以用戶A的身份登錄到遠程主機上。

 

     公鑰認證機制的一種變體是證書認證:只有被信任的證書才允許連接。詳細信息見

     ssh-keygen(1)的CERTIFICATES段說明。

 

     使用公鑰認證機制或證書認證機制最方便的方法是"認證代理",

     詳細信息見ssh-agent(1)和ssh_config(5)中的AddKeysToAgent指令段。

 

     Challenge-response authentication works as follows: The server sends an

     arbitrary "challenge" text, and prompts for a response.  Examples of

     challenge-response authentication include BSD Authentication (see

     login.conf(5)) and PAM (some non-OpenBSD systems).

 

     最后,如果所有認證方法都失敗,將提示輸入密碼。輸入的密碼將被加密傳送,

     然后被服務端檢測是否正確。

 

     SSH客戶端自動維護和檢查一個主機認證信息數據庫,所有已知的主機公鑰都會

     記錄到此文件中。主機信息條目(host key)存放在~/.ssh/known_hosts文件中。

     另外,在檢查host key時,/etc/ssh_known_hosts也會被自動檢測。

     當host key被改變時,ssh將發出警告,並禁止密鑰認證機制以防止服務端欺騙

     或中間人攻擊。選項StrictHostKeyChecking選項可用於控制登錄時那些未知host key

     如何處理。

 

     當客戶端被服務端接受,服務段將以非交互會話執行給定的命令,若沒有給定命令,

     則登錄到服務端,並進入到交互會話模式,同時會為登錄的用戶分配shell,之后

     所有的交互信息都將被加密傳輸。

    

     ssh默認會請求交互式會話,這將請求一個偽終端(pty),使用"-T"或"-t"選項可以

     改變該行為,"-T"是禁止分配偽終端,"-t"則是強制分配偽終端,可使用"-tt"

     表示進一步強制。

 

     如果為ssh分配了偽終端,則用戶可以在此偽終端中使用逃逸字符實現特殊控制。

 

     如果未分配偽終端給ssh,則連接會話是透明的,可以用來可靠傳輸二進制數據。

     如果設置逃逸字符為"none",將使得會話透明,即使它使用了tty終端。

     當命令結束或shell退出時將終止會話連接,所有的X11和TCP連接也都被關閉。

 

逃逸字符

     當分配了偽終端時,ssh支持一系列的逃逸字符實現特殊功能。

     默認的逃逸首字符為"~",其后可跟某些特定字符(如下列出),逃逸字符必須放

     在行尾以實現特定的中斷。可在配置文件中使用EscapeChar指令或命令行的"-e"

     選項來改變逃逸首字符。

     ~.      禁止連接

     ~^Z     將ssh放入后台

     ~#      列出已轉發的連接

     ~&      Background ssh at logout when waiting for forwarded connection /

               X11 sessions to terminate.

     ~?      列出逃逸字符列表

     ~B      發送BREAK信號給遠程主機

     ~C      打開命令行。Open command line.  Currently this allows the addition of port

             forwardings using the -L, -R and -D options (see above).  It also

             allows the cancellation of existing port-forwardings with

             -KL[bind_address:]port for local, -KR[bind_address:]port for

             remote and -KD[bind_address:]port for dynamic port-forwardings.

             !command allows the user to execute a local command if the

             PermitLocalCommand option is enabled in ssh_config(5).  Basic

             help is available, using the -h option.

     ~R      請求該會話進行密鑰更新

     ~V      當錯誤被寫入到stderr時,降低信息的詳細程度(loglevel)

     ~v      當錯誤被寫入到stderr時,增加信息的詳細程度

 

TCP轉發

     可在配置文件或命令行選項上開啟基於安全隧道的任意TCP連接轉發功能。

     一個TCP轉發可能的應用場景是為了安全連接到郵件服務器,其他場景則主要

     是為了穿過防火牆。

 

     下面的例子中,建立了IRC客戶端和服務端的加密連接,盡管IRC服務端不直

     接支持加密連接。用戶在本地指定一個用於轉發到遠程服務器上的端口,這

     樣在本地主機上將開啟一個加密的服務,當連接到本地轉發端口時,ssh將

     加密和轉發此連接。  

 

     下面的示例中,從客戶端主機"127.0.0.1"到"server.example.com"的連接將

     使用隧道技術。

 

         $ ssh -f -L 1234:localhost:6667 server.example.com sleep 10

         $ irc -c '#users' -p 1234 pinky 127.0.0.1

 

     這個隧道建立在本地和"server.example.com"之間,隧道傳遞的內容有:

     “#users","pinky",using port 1234. 無論使用的是什么端口,只要大於

     1023(只有root可以在特權端口上建立套接字),即使端口已被使用也不

     會發生沖突。連接將被轉發到遠程主機的6667端口上,因為IRC服務的

     默認端口為6667。

 

     "-f"選項將ssh放入后台,而遠程命令"sleep 10"則表示在一段時間(10秒)

     內的連接將通過隧道傳輸。如果在10秒內沒有連接,則ssh退出。

     (也就是說該隧道只在后台保持10秒鍾。)

 

X11 FORWARDING

     If the ForwardX11 variable is set to “yes” (or see the description of

     the -X, -x, and -Y options above) and the user is using X11 (the DISPLAY

     environment variable is set), the connection to the X11 display is auto‐

     matically forwarded to the remote side in such a way that any X11 pro‐

     grams started from the shell (or command) will go through the encrypted

     channel, and the connection to the real X server will be made from the

     local machine.  The user should not manually set DISPLAY.  Forwarding of

     X11 connections can be configured on the command line or in configuration

     files.

 

     The DISPLAY value set by ssh will point to the server machine, but with a

     display number greater than zero.  This is normal, and happens because

     ssh creates a “proxy” X server on the server machine for forwarding the

     connections over the encrypted channel.

 

     ssh will also automatically set up Xauthority data on the server machine.

     For this purpose, it will generate a random authorization cookie, store

     it in Xauthority on the server, and verify that any forwarded connections

     carry this cookie and replace it by the real cookie when the connection

     is opened.  The real authentication cookie is never sent to the server

     machine (and no cookies are sent in the plain).

 

     If the ForwardAgent variable is set to “yes” (or see the description of

     the -A and -a options above) and the user is using an authentication

     agent, the connection to the agent is automatically forwarded to the

     remote side.

 

VERIFYING HOST KEYS

     當用戶第一次連接到一個服務端,將輸出服務端公鑰的指紋(fingerprint)給用戶

     (除非StrictHostKeyChecking配置被禁用了)。這些指紋可通過ssh-keygen來計算。

 

           $ ssh-keygen -l -f /etc/ssh/ssh_host_rsa_key

 

     如果某指紋已經存在,可決定對應的密鑰是接受還是拒絕。如果僅能獲取到服

     務端的傳統指紋(MD5),ssh-keygen的"-E"選項可能會將指紋降級以做指紋匹配。

 

     由於僅通過查找指紋來比較host key比較困難,所以也支持使用隨機數的方式

     可視化比較host key。通過設置VisualHostKey選項為"yes",客戶端連接服務

     端時將顯示一小段ASCII圖形信息(即圖形化的指紋),無論會話是否是需要交互

     的。通過比較已生成的圖形指紋,用戶可以輕松地找出host key是否發生了改

     變。但是,由於圖形指紋不是很明了,所以相似的圖形指紋並不能保證host key

     是沒有改變過的,只不過通過圖形指紋的方式提供了一個比較好的比較方式。

    

     要獲取所有已知主機(known host)的圖形指紋列表,使用下面的命令:

 

           $ ssh-keygen -lv -f ~/.ssh/known_hosts

 

     如果指紋是未知的,有一種方法可以驗證它:使用DNS。可在DNS的區域文件中添

     加資源記錄SSHFP,這樣客戶端就可以匹配那些已存在的主機指紋。

    

     在下面的例子中,將使用客戶端連接到服務端"host.example.com"。但在此之前,

     應該先將"host.example.com"的SSHFP資源記錄添加到DNS區域文件中:

 

           $ ssh-keygen -r host.example.com.

 

     將上面命令的輸出結果添加到區域文件中。可以檢查該資源記錄是否可解析:

 

           $ dig -t SSHFP host.example.com

 

     最后使用客戶端去連接服務端:

 

           $ ssh -o "VerifyHostKeyDNS ask" host.example.com

           [...]

           Matching host key fingerprint found in DNS.

           Are you sure you want to continue connecting (yes/no)?

 

     更多信息請查看ssh_config(5)的VerifyHostKeyDNS選項說明段。

 

SSH-BASED VIRTUAL PRIVATE NETWORKS

     The following example would connect client network 10.0.50.0/24 with

     remote network 10.0.99.0/24 using a point-to-point connection from

     10.1.1.1 to 10.1.1.2, provided that the SSH server running on the gateway

     to the remote network, at 192.168.1.15, allows it.

 

     on client:

 

           # ssh -f -w 0:1 192.168.1.15 true

           # ifconfig tun0 10.1.1.1 10.1.1.2 netmask 255.255.255.252

           # route add 10.0.99.0/24 10.1.1.2

 

     on server:

 

           # ifconfig tun1 10.1.1.2 10.1.1.1 netmask 255.255.255.252

           # route add 10.0.50.0/24 10.1.1.1

 

     Client access may be more finely tuned via the /root/.ssh/authorized_keys

     file (see below) and the PermitRootLogin server option.  The following

     entry would permit connections on tun(4) device 1 from user “jane” and

     on tun device 2 from user “john”, if PermitRootLogin is set to

     “forced-commands-only”:

 

       tunnel="1",command="sh /etc/netstart tun1" ssh-rsa ... jane

       tunnel="2",command="sh /etc/netstart tun2" ssh-rsa ... john

 

     Since an SSH-based setup entails a fair amount of overhead, it may be

     more suited to temporary setups, such as for wireless VPNs.  More perma‐

     nent VPNs are better provided by tools such as ipsecctl(8) and

     isakmpd(8).

 

ENVIRONMENT

     ssh will normally set the following environment variables:

 

     DISPLAY               The DISPLAY variable indicates the location of the

                           X11 server.  It is automatically set by ssh to

                           point to a value of the form “hostname:n”, where

                           “hostname” indicates the host where the shell

                           runs, and ‘n’ is an integer ≥ 1.  ssh uses this

                           special value to forward X11 connections over the

                           secure channel.  The user should normally not set

                           DISPLAY explicitly, as that will render the X11

                           connection insecure (and will require the user to

                           manually copy any required authorization cookies).

 

     HOME                  Set to the path of the user's home directory.

 

     LOGNAME               Synonym for USER; set for compatibility with sys‐

                           tems that use this variable.

 

     MAIL                  Set to the path of the user's mailbox.

 

     PATH                  Set to the default PATH, as specified when compil‐

                           ing ssh.

 

     SSH_ASKPASS           If ssh needs a passphrase, it will read the

                           passphrase from the current terminal if it was run

                           from a terminal.  If ssh does not have a terminal

                           associated with it but DISPLAY and SSH_ASKPASS are

                           set, it will execute the program specified by

                           SSH_ASKPASS and open an X11 window to read the

                           passphrase.  This is particularly useful when

                           calling ssh from a .xsession or related script.

                           (Note that on some machines it may be necessary to

                           redirect the input from /dev/null to make this

                           work.)

 

     SSH_AUTH_SOCK         Identifies the path of a UNIX-domain socket used to

                           communicate with the agent.

 

     SSH_CONNECTION        Identifies the client and server ends of the con‐

                           nection.  The variable contains four space-sepa‐

                           rated values: client IP address, client port num‐

                           ber, server IP address, and server port number.

 

     SSH_ORIGINAL_COMMAND  This variable contains the original command line if

                           a forced command is executed.  It can be used to

                           extract the original arguments.

 

     SSH_TTY               This is set to the name of the tty (path to the

                           device) associated with the current shell or com‐

                           mand.  If the current session has no tty, this

                           variable is not set.

 

     TZ                    This variable is set to indicate the present time

                           zone if it was set when the daemon was started

                           (i.e. the daemon passes the value on to new con‐

                           nections).

 

     USER                  Set to the name of the user logging in.

 

     Additionally, ssh reads ~/.ssh/environment, and adds lines of the format

     “VARNAME=value” to the environment if the file exists and users are

     allowed to change their environment.  For more information, see the

     PermitUserEnvironment option in sshd_config(5).

 

FILES

     ~/.rhosts

             這個文件用於基於主機的認證機制(見上文),里面列出允許登錄的

             主機/用戶對。該文件屬主必須是這個對應的用戶,且其它用戶不

             能有寫權限。但如果用戶家目錄位於NFS分區上時,該文件要求全

             局可讀,因為sshd(8)使用root身份讀取該文件。大多數情況下,

             推薦權限為"600"。

     ~/.shosts

             該文件的用法與".rhosts"完全一樣,但允許基於主機認證的同時

             禁止使用"rlogin/rsh"登錄。

     ~/.ssh/

             該目錄是所有用戶配置文件和用戶認證信息的默認放置目錄。雖然

             沒有規定要保證該目錄中內容的安全,但推薦其內文件只對所有者

             有讀/寫/執行權限,對其他人完全拒絕

     ~/.ssh/authorized_keys

             該文件列出了可以用來登錄的用戶的公鑰(DSA,ECDSA,Ed25519,RSA)。

             在sshd(8)的man文檔中描述了該文件的格式。該文件不需要高安全性,

             但推薦只有其所有者有讀/寫權限,對其他人完全拒絕

     ~/.ssh/config

             該文件是ssh的用戶配置文件。在ssh_config(5)的man文檔中描述了該

             文件的格式。由於可能會濫用該文件,該文件有嚴格的權限要求:只

             對所有者有讀/寫權限,對其他人完全拒絕寫權限

     ~/.ssh/environment

             包含了額外定義的環境變量。見上文ENVIRONMENT。

     ~/.ssh/identity

     ~/.ssh/id_dsa

     ~/.ssh/id_ecdsa

     ~/.ssh/id_ed25519

     ~/.ssh/id_rsa

             包含了認證的私鑰。這些文件包含了敏感數據,應該只對所有者可讀,

             並拒絕其他人的所有權限(rwx)。如果該文件可被其他人訪問,則ssh

             會忽略該文件。可以在生產密鑰文件的時候指定passphrase使用3DES

             算法加密該文件。

     ~/.ssh/identity.pub

     ~/.ssh/id_dsa.pub

     ~/.ssh/id_ecdsa.pub

     ~/.ssh/id_ed25519.pub

     ~/.ssh/id_rsa.pub

             包含了認證時的公鑰。這些文件中的數據不敏感,允許任何人讀取。

     ~/.ssh/known_hosts

             包含了所有已知主機的host key列表。該文件的詳細格式見sshd(8)。

     ~/.ssh/rc

             該文件包含了用戶使用ssh登錄成功,但啟用shell(或指定命令執行)

             之前執行的命令。詳細信息見sshd(8)的man文檔。

             (譯者注:也就是說,登錄成功后做的第一件事就是執行該文件中的

             命令)

     /etc/ssh/hosts.equiv

             該文件是基於主機認證的文件(見上文)。應該只能讓root有寫權限。

     /etc/ssh/shosts.equiv

             用法等同於"hosts.equiv",但允許基於主機認證的同時禁止使用

             "rlogin/rsh"登錄。

     /etc/ssh/ssh_config

             ssh的全局配置文件。該文件的格式和選項信息見ssh_config(5)。

     /etc/ssh/ssh_host_key

     /etc/ssh/ssh_host_dsa_key

     /etc/ssh/ssh_host_ecdsa_key

     /etc/ssh/ssh_host_ed25519_key

     /etc/ssh/ssh_host_rsa_key

             這些文件包含了host key的私密部分信息,它們用於基於主機認證。

             (譯者注:服務端生成的私鑰,主機驗證時會將對應公鑰存入到客戶

               端的known_hosts文件中,這些文件在sshd服務重啟時會自動生成)

     /etc/ssh/ssh_known_hosts

             已知host key的全局列表文件。該文件中要包含的host key應該由

             系統管理員准備好。該文件應該要全局可讀。詳細信息見sshd(8)。

     /etc/ssh/rc

             等同於~/.ssh/rc文件,包含了用戶使用ssh登錄成功,但啟用shell

             (或指定命令執行)之前執行的命令。詳細信息見sshd(8)的man文檔。

             (譯者注:也就是說,登錄成功后做的第一件事就是執行該文件中的

             命令)

 

退出狀態碼

     ssh將以遠程命令執行結果為狀態碼退出,或者出現錯誤時以255狀態碼退出。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM