📄 ssh.1
字号:
.\" -*- nroff -*-.\".\" Author: Tatu Ylonen <ylo@cs.hut.fi>.\" Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland.\" All rights reserved.\".\" As far as I am concerned, the code I have written for this software.\" can be used freely for any purpose. Any derived versions of this.\" software must be clearly marked as such, and if the derived work is.\" incompatible with the protocol description in the RFC file, it must be.\" called by a name other than "ssh" or "Secure Shell"..\".\" Copyright (c) 1999,2000 Markus Friedl. All rights reserved..\" Copyright (c) 1999 Aaron Campbell. All rights reserved..\" Copyright (c) 1999 Theo de Raadt. All rights reserved..\".\" Redistribution and use in source and binary forms, with or without.\" modification, are permitted provided that the following conditions.\" are met:.\" 1. Redistributions of source code must retain the above copyright.\" notice, this list of conditions and the following disclaimer..\" 2. Redistributions in binary form must reproduce the above copyright.\" notice, this list of conditions and the following disclaimer in the.\" documentation and/or other materials provided with the distribution..\".\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED..\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE..\".\" $OpenBSD: ssh.1,v 1.205 2005/03/07 23:41:54 jmc Exp $.Dd September 25, 1999.Dt SSH 1.Os.Sh NAME.Nm ssh.Nd OpenSSH SSH client (remote login program).Sh SYNOPSIS.Nm ssh.Bk -words.Op Fl 1246AaCfgkMNnqsTtVvXxY.Op Fl b Ar bind_address.Op Fl c Ar cipher_spec.Op Fl D Ar port.Op Fl e Ar escape_char.Op Fl F Ar configfile.Op Fl i Ar identity_file.Oo Fl L\ \&.Sm off.Oo Ar bind_address : Oc.Ar port : host : hostport.Sm on.Oc.Op Fl l Ar login_name.Op Fl m Ar mac_spec.Op Fl O Ar ctl_cmd.Op Fl o Ar option.Op Fl p Ar port.Oo Fl R\ \&.Sm off.Oo Ar bind_address : Oc.Ar port : host : hostport.Sm on.Oc.Op Fl S Ar ctl_path.Oo Ar user Ns @ Oc Ns Ar hostname.Op Ar command.Ek.Sh DESCRIPTION.Nm(SSH client) is a program for logging into a remote machine and forexecuting commands on a remote machine.It is intended to replace rlogin and rsh,and provide secure encrypted communications betweentwo untrusted hosts over an insecure network.X11 connections and arbitrary TCP/IP portscan also be forwarded over the secure channel..Pp.Nmconnects and logs into the specified.Ar hostname(with optional.Ar username).The user must provehis/her identity to the remote machine using one of several methodsdepending on the protocol version used..PpIf.Ar commandis specified,.Ar commandis executed on the remote host instead of a login shell..Ss SSH protocol version 1The first authentication method is the.Em rhostsor.Em hosts.equivmethod combined with RSA-based host authentication.If the machine the user logs in from is listed in.Pa /etc/hosts.equivor.Pa /etc/shosts.equivon the remote machine, and the user names arethe same on both sides, or if the files.Pa $HOME/.rhostsor.Pa $HOME/.shostsexist in the user's home directory on theremote machine and contain a line containing the name of the clientmachine and the name of the user on that machine, the user isconsidered for log in.Additionally, if the server can verify the client'shost key (see.Pa /etc/ssh/ssh_known_hostsand.Pa $HOME/.ssh/known_hostsin the.Sx FILESsection), only then is login permitted.This authentication method closes security holes due to IPspoofing, DNS spoofing and routing spoofing.[Note to the administrator:.Pa /etc/hosts.equiv ,.Pa $HOME/.rhosts ,and the rlogin/rsh protocol in general, are inherently insecure and should bedisabled if security is desired.].PpAs a second authentication method,.Nmsupports RSA based authentication.The scheme is based on public-key cryptography: there are cryptosystemswhere encryption and decryption are done using separate keys, and itis not possible to derive the decryption key from the encryption key.RSA is one such system.The idea is that each user creates a public/privatekey pair for authentication purposes.The server knows the public key, and only the user knows the private key..PpThe file.Pa $HOME/.ssh/authorized_keyslists the public keys that are permitted for logging in.When the user logs in, the.Nmprogram tells the server which key pair it would like to use forauthentication.The server checks if this key is permitted, and if so,sends the user (actually the.Nmprogram running on behalf of the user) a challenge, a random number,encrypted by the user's public key.The challenge can only be decrypted using the proper private key.The user's client then decrypts the challenge using the private key,proving that he/she knows the private keybut without disclosing it to the server..Pp.Nmimplements the RSA authentication protocol automatically.The user creates his/her RSA key pair by running.Xr ssh-keygen 1 .This stores the private key in.Pa $HOME/.ssh/identityand stores the public key in.Pa $HOME/.ssh/identity.pubin the user's home directory.The user should then copy the.Pa identity.pubto.Pa $HOME/.ssh/authorized_keysin his/her home directory on the remote machine (the.Pa authorized_keysfile corresponds to the conventional.Pa $HOME/.rhostsfile, and has one keyper line, though the lines can be very long).After this, the user can log in without giving the password..PpThe most convenient way to use RSA authentication may be with anauthentication agent.See.Xr ssh-agent 1for more information..PpIf other authentication methods fail,.Nmprompts the user for a password.The password is sent to the remotehost for checking; however, since all communications are encrypted,the password cannot be seen by someone listening on the network..Ss SSH protocol version 2When a user connects using protocol version 2,similar authentication methods are available.Using the default values for.Cm PreferredAuthentications ,the client will try to authenticate first using the hostbased method;if this method fails, public key authentication is attempted,and finally if this method fails, keyboard-interactive andpassword authentication are tried..PpThe public key method is similar to RSA authentication describedin the previous section and allows the RSA or DSA algorithm to be used:The client uses his private key,.Pa $HOME/.ssh/id_dsaor.Pa $HOME/.ssh/id_rsa ,to sign the session identifier and sends the result to the server.The server checks whether the matching public key is listed in.Pa $HOME/.ssh/authorized_keysand grants access if both the key is found and the signature is correct.The session identifier is derived from a shared Diffie-Hellman valueand is only known to the client and the server..PpIf public key authentication fails or is not available, a passwordcan be sent encrypted to the remote host to prove the user's identity..PpAdditionally,.Nmsupports hostbased or challenge response authentication..PpProtocol 2 provides additional mechanisms for confidentiality(the traffic is encrypted using AES, 3DES, Blowfish, CAST128 or Arcfour)and integrity (hmac-md5, hmac-sha1, hmac-ripemd160).Note that protocol 1 lacks a strong mechanism for ensuring theintegrity of the connection..Ss Login session and remote executionWhen the user's identity has been accepted by the server, the servereither executes the given command, or logs into the machine and givesthe user a normal shell on the remote machine.All communication withthe remote command or shell will be automatically encrypted..PpIf a pseudo-terminal has been allocated (normal login session), theuser may use the escape characters noted below..PpIf no pseudo-tty has been allocated,the session is transparent and can be used to reliably transfer binary data.On most systems, setting the escape character to.Dq nonewill also make the session transparent even if a tty is used..PpThe session terminates when the command or shell on the remotemachine exits and all X11 and TCP/IP connections have been closed.The exit status of the remote program is returned as the exit status of.Nm ssh ..Ss Escape CharactersWhen a pseudo-terminal has been requested,.Nmsupports a number of functions through the use of an escape character..PpA single tilde character can be sent as.Ic ~~or by following the tilde by a character other than those described below.The escape character must always follow a newline to be interpreted asspecial.The escape character can be changed in configuration files using the.Cm EscapeCharconfiguration directive or on the command line by the.Fl eoption..PpThe supported escapes (assuming the default.Ql ~ )are:.Bl -tag -width Ds.It Cm ~.Disconnect..It Cm ~^ZBackground.Nm ssh ..It Cm ~#List forwarded connections..It Cm ~&Background.Nmat logout when waiting for forwarded connection / X11 sessions to terminate..It Cm ~?Display a list of escape characters..It Cm ~BSend a BREAK to the remote system(only useful for SSH protocol version 2 and if the peer supports it)..It Cm ~COpen command line.Currently this allows the addition of port forwardings using the.Fl Land.Fl Roptions (see below).It also allows the cancellation of existing remote port-forwardingsusing.Fl KR Ar hostport .Basic help is available, using the.Fl hoption..It Cm ~RRequest rekeying of the connection(only useful for SSH protocol version 2 and if the peer supports it)..El.Ss X11 and TCP forwardingIf the.Cm ForwardX11variable is set to.Dq yes(or see the description of the.Fl Xand.Fl xoptions described later)and the user is using X11 (the.Ev DISPLAYenvironment variable is set), the connection to the X11 display isautomatically forwarded to the remote side in such a way that any X11programs started from the shell (or command) will go through theencrypted channel, and the connection to the real X server will be madefrom the local machine.The user should not manually set.Ev DISPLAY .Forwarding of X11 connections can beconfigured on the command line or in configuration files..PpThe.Ev DISPLAYvalue set by.Nmwill point to the server machine, but with a display number greater than zero.This is normal, and happens because.Nmcreates a.Dq proxyX server on the server machine for forwarding theconnections over the encrypted channel..Pp.Nmwill 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 forwardedconnections carry this cookie and replace it by the real cookie whenthe connection is opened.The real authentication cookie is neversent to the server machine (and no cookies are sent in the plain)..PpIf the.Cm ForwardAgentvariable is set to.Dq yes(or see the description of the.Fl Aand.Fl aoptions described later) andthe user is using an authentication agent, the connection to the agentis automatically forwarded to the remote side..PpForwarding of arbitrary TCP/IP connections over the secure channel canbe specified either on the command line or in a configuration file.One possible application of TCP/IP forwarding is a secure connection to anelectronic purse; another is going through firewalls..Ss Server authentication.Nmautomatically maintains and checks a database containingidentifications for all hosts it has ever been used with.Host keys are stored in.Pa $HOME/.ssh/known_hostsin the user's home directory.Additionally, the file.Pa /etc/ssh/ssh_known_hostsis automatically checked for known hosts.Any new hosts are automatically added to the user's file.If a host's identification ever changes,.Nmwarns about this and disables password authentication to prevent atrojan horse from getting the user's password.Another purpose of this mechanism is to prevent man-in-the-middle attackswhich could otherwise be used to circumvent the encryption.The.Cm StrictHostKeyCheckingoption can be used to prevent logins to machines whosehost key is not known or has changed..Pp.Nmcan be configured to verify host identification using fingerprint resourcerecords (SSHFP) published in DNS.The.Cm VerifyHostKeyDNSoption can be used to control how DNS lookups are performed.SSHFP resource records can be generated using.Xr ssh-keygen 1 ..PpThe options are as follows:.Bl -tag -width Ds.It Fl 1
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -