ssh.1 46 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771
  1. .\"
  2. .\" Author: Tatu Ylonen <ylo@cs.hut.fi>
  3. .\" Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
  4. .\" All rights reserved
  5. .\"
  6. .\" As far as I am concerned, the code I have written for this software
  7. .\" can be used freely for any purpose. Any derived versions of this
  8. .\" software must be clearly marked as such, and if the derived work is
  9. .\" incompatible with the protocol description in the RFC file, it must be
  10. .\" called by a name other than "ssh" or "Secure Shell".
  11. .\"
  12. .\" Copyright (c) 1999,2000 Markus Friedl. All rights reserved.
  13. .\" Copyright (c) 1999 Aaron Campbell. All rights reserved.
  14. .\" Copyright (c) 1999 Theo de Raadt. All rights reserved.
  15. .\"
  16. .\" Redistribution and use in source and binary forms, with or without
  17. .\" modification, are permitted provided that the following conditions
  18. .\" are met:
  19. .\" 1. Redistributions of source code must retain the above copyright
  20. .\" notice, this list of conditions and the following disclaimer.
  21. .\" 2. Redistributions in binary form must reproduce the above copyright
  22. .\" notice, this list of conditions and the following disclaimer in the
  23. .\" documentation and/or other materials provided with the distribution.
  24. .\"
  25. .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
  26. .\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  27. .\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  28. .\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  29. .\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  30. .\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  31. .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  32. .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  33. .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  34. .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  35. .\"
  36. .\" $OpenBSD: ssh.1,v 1.414 2020/07/15 05:40:05 jmc Exp $
  37. .Dd $Mdocdate: July 15 2020 $
  38. .Dt SSH 1
  39. .Os
  40. .Sh NAME
  41. .Nm ssh
  42. .Nd OpenSSH remote login client
  43. .Sh SYNOPSIS
  44. .Nm ssh
  45. .Op Fl 46AaCfGgKkMNnqsTtVvXxYy
  46. .Op Fl B Ar bind_interface
  47. .Op Fl b Ar bind_address
  48. .Op Fl c Ar cipher_spec
  49. .Op Fl D Oo Ar bind_address : Oc Ns Ar port
  50. .Op Fl E Ar log_file
  51. .Op Fl e Ar escape_char
  52. .Op Fl F Ar configfile
  53. .Op Fl I Ar pkcs11
  54. .Op Fl i Ar identity_file
  55. .Op Fl J Ar destination
  56. .Op Fl L Ar address
  57. .Op Fl l Ar login_name
  58. .Op Fl m Ar mac_spec
  59. .Op Fl O Ar ctl_cmd
  60. .Op Fl o Ar option
  61. .Op Fl p Ar port
  62. .Op Fl Q Ar query_option
  63. .Op Fl R Ar address
  64. .Op Fl S Ar ctl_path
  65. .Op Fl W Ar host : Ns Ar port
  66. .Op Fl w Ar local_tun Ns Op : Ns Ar remote_tun
  67. .Ar destination
  68. .Op Ar command
  69. .Sh DESCRIPTION
  70. .Nm
  71. (SSH client) is a program for logging into a remote machine and for
  72. executing commands on a remote machine.
  73. It is intended to provide secure encrypted communications between
  74. two untrusted hosts over an insecure network.
  75. X11 connections, arbitrary TCP ports and
  76. .Ux Ns -domain
  77. sockets can also be forwarded over the secure channel.
  78. .Pp
  79. .Nm
  80. connects and logs into the specified
  81. .Ar destination ,
  82. which may be specified as either
  83. .Sm off
  84. .Oo user @ Oc hostname
  85. .Sm on
  86. or a URI of the form
  87. .Sm off
  88. .No ssh:// Oo user @ Oc hostname Op : port .
  89. .Sm on
  90. The user must prove
  91. his/her identity to the remote machine using one of several methods
  92. (see below).
  93. .Pp
  94. If a
  95. .Ar command
  96. is specified,
  97. it is executed on the remote host instead of a login shell.
  98. .Pp
  99. The options are as follows:
  100. .Pp
  101. .Bl -tag -width Ds -compact
  102. .It Fl 4
  103. Forces
  104. .Nm
  105. to use IPv4 addresses only.
  106. .Pp
  107. .It Fl 6
  108. Forces
  109. .Nm
  110. to use IPv6 addresses only.
  111. .Pp
  112. .It Fl A
  113. Enables forwarding of connections from an authentication agent such as
  114. .Xr ssh-agent 1 .
  115. This can also be specified on a per-host basis in a configuration file.
  116. .Pp
  117. Agent forwarding should be enabled with caution.
  118. Users with the ability to bypass file permissions on the remote host
  119. (for the agent's
  120. .Ux Ns -domain
  121. socket) can access the local agent through the forwarded connection.
  122. An attacker cannot obtain key material from the agent,
  123. however they can perform operations on the keys that enable them to
  124. authenticate using the identities loaded into the agent.
  125. A safer alternative may be to use a jump host
  126. (see
  127. .Fl J ) .
  128. .Pp
  129. .It Fl a
  130. Disables forwarding of the authentication agent connection.
  131. .Pp
  132. .It Fl B Ar bind_interface
  133. Bind to the address of
  134. .Ar bind_interface
  135. before attempting to connect to the destination host.
  136. This is only useful on systems with more than one address.
  137. .Pp
  138. .It Fl b Ar bind_address
  139. Use
  140. .Ar bind_address
  141. on the local machine as the source address
  142. of the connection.
  143. Only useful on systems with more than one address.
  144. .Pp
  145. .It Fl C
  146. Requests compression of all data (including stdin, stdout, stderr, and
  147. data for forwarded X11, TCP and
  148. .Ux Ns -domain
  149. connections).
  150. The compression algorithm is the same used by
  151. .Xr gzip 1 .
  152. Compression is desirable on modem lines and other
  153. slow connections, but will only slow down things on fast networks.
  154. The default value can be set on a host-by-host basis in the
  155. configuration files; see the
  156. .Cm Compression
  157. option.
  158. .Pp
  159. .It Fl c Ar cipher_spec
  160. Selects the cipher specification for encrypting the session.
  161. .Ar cipher_spec
  162. is a comma-separated list of ciphers
  163. listed in order of preference.
  164. See the
  165. .Cm Ciphers
  166. keyword in
  167. .Xr ssh_config 5
  168. for more information.
  169. .Pp
  170. .It Fl D Xo
  171. .Sm off
  172. .Oo Ar bind_address : Oc
  173. .Ar port
  174. .Sm on
  175. .Xc
  176. Specifies a local
  177. .Dq dynamic
  178. application-level port forwarding.
  179. This works by allocating a socket to listen to
  180. .Ar port
  181. on the local side, optionally bound to the specified
  182. .Ar bind_address .
  183. Whenever a connection is made to this port, the
  184. connection is forwarded over the secure channel, and the application
  185. protocol is then used to determine where to connect to from the
  186. remote machine.
  187. Currently the SOCKS4 and SOCKS5 protocols are supported, and
  188. .Nm
  189. will act as a SOCKS server.
  190. Only root can forward privileged ports.
  191. Dynamic port forwardings can also be specified in the configuration file.
  192. .Pp
  193. IPv6 addresses can be specified by enclosing the address in square brackets.
  194. Only the superuser can forward privileged ports.
  195. By default, the local port is bound in accordance with the
  196. .Cm GatewayPorts
  197. setting.
  198. However, an explicit
  199. .Ar bind_address
  200. may be used to bind the connection to a specific address.
  201. The
  202. .Ar bind_address
  203. of
  204. .Dq localhost
  205. indicates that the listening port be bound for local use only, while an
  206. empty address or
  207. .Sq *
  208. indicates that the port should be available from all interfaces.
  209. .Pp
  210. .It Fl E Ar log_file
  211. Append debug logs to
  212. .Ar log_file
  213. instead of standard error.
  214. .Pp
  215. .It Fl e Ar escape_char
  216. Sets the escape character for sessions with a pty (default:
  217. .Ql ~ ) .
  218. The escape character is only recognized at the beginning of a line.
  219. The escape character followed by a dot
  220. .Pq Ql \&.
  221. closes the connection;
  222. followed by control-Z suspends the connection;
  223. and followed by itself sends the escape character once.
  224. Setting the character to
  225. .Dq none
  226. disables any escapes and makes the session fully transparent.
  227. .Pp
  228. .It Fl F Ar configfile
  229. Specifies an alternative per-user configuration file.
  230. If a configuration file is given on the command line,
  231. the system-wide configuration file
  232. .Pq Pa /etc/ssh/ssh_config
  233. will be ignored.
  234. The default for the per-user configuration file is
  235. .Pa ~/.ssh/config .
  236. If set to
  237. .Dq none ,
  238. no configuration files will be read.
  239. .Pp
  240. .It Fl f
  241. Requests
  242. .Nm
  243. to go to background just before command execution.
  244. This is useful if
  245. .Nm
  246. is going to ask for passwords or passphrases, but the user
  247. wants it in the background.
  248. This implies
  249. .Fl n .
  250. The recommended way to start X11 programs at a remote site is with
  251. something like
  252. .Ic ssh -f host xterm .
  253. .Pp
  254. If the
  255. .Cm ExitOnForwardFailure
  256. configuration option is set to
  257. .Dq yes ,
  258. then a client started with
  259. .Fl f
  260. will wait for all remote port forwards to be successfully established
  261. before placing itself in the background.
  262. Refer to the description of
  263. .Cm ForkAfterAuthentication
  264. in
  265. .Xr ssh_config 5
  266. for details.
  267. .Pp
  268. .It Fl G
  269. Causes
  270. .Nm
  271. to print its configuration after evaluating
  272. .Cm Host
  273. and
  274. .Cm Match
  275. blocks and exit.
  276. .Pp
  277. .It Fl g
  278. Allows remote hosts to connect to local forwarded ports.
  279. If used on a multiplexed connection, then this option must be specified
  280. on the master process.
  281. .Pp
  282. .It Fl I Ar pkcs11
  283. Specify the PKCS#11 shared library
  284. .Nm
  285. should use to communicate with a PKCS#11 token providing keys for user
  286. authentication.
  287. .Pp
  288. .It Fl i Ar identity_file
  289. Selects a file from which the identity (private key) for
  290. public key authentication is read.
  291. The default is
  292. .Pa ~/.ssh/id_dsa ,
  293. .Pa ~/.ssh/id_ecdsa ,
  294. .Pa ~/.ssh/id_ecdsa_sk ,
  295. .Pa ~/.ssh/id_ed25519 ,
  296. .Pa ~/.ssh/id_ed25519_sk
  297. and
  298. .Pa ~/.ssh/id_rsa .
  299. Identity files may also be specified on
  300. a per-host basis in the configuration file.
  301. It is possible to have multiple
  302. .Fl i
  303. options (and multiple identities specified in
  304. configuration files).
  305. If no certificates have been explicitly specified by the
  306. .Cm CertificateFile
  307. directive,
  308. .Nm
  309. will also try to load certificate information from the filename obtained
  310. by appending
  311. .Pa -cert.pub
  312. to identity filenames.
  313. .Pp
  314. .It Fl J Ar destination
  315. Connect to the target host by first making a
  316. .Nm
  317. connection to the jump host described by
  318. .Ar destination
  319. and then establishing a TCP forwarding to the ultimate destination from
  320. there.
  321. Multiple jump hops may be specified separated by comma characters.
  322. This is a shortcut to specify a
  323. .Cm ProxyJump
  324. configuration directive.
  325. Note that configuration directives supplied on the command-line generally
  326. apply to the destination host and not any specified jump hosts.
  327. Use
  328. .Pa ~/.ssh/config
  329. to specify configuration for jump hosts.
  330. .Pp
  331. .It Fl K
  332. Enables GSSAPI-based authentication and forwarding (delegation) of GSSAPI
  333. credentials to the server.
  334. .Pp
  335. .It Fl k
  336. Disables forwarding (delegation) of GSSAPI credentials to the server.
  337. .Pp
  338. .It Fl L Xo
  339. .Sm off
  340. .Oo Ar bind_address : Oc
  341. .Ar port : host : hostport
  342. .Sm on
  343. .Xc
  344. .It Fl L Xo
  345. .Sm off
  346. .Oo Ar bind_address : Oc
  347. .Ar port : remote_socket
  348. .Sm on
  349. .Xc
  350. .It Fl L Xo
  351. .Sm off
  352. .Ar local_socket : host : hostport
  353. .Sm on
  354. .Xc
  355. .It Fl L Xo
  356. .Sm off
  357. .Ar local_socket : remote_socket
  358. .Sm on
  359. .Xc
  360. Specifies that connections to the given TCP port or Unix socket on the local
  361. (client) host are to be forwarded to the given host and port, or Unix socket,
  362. on the remote side.
  363. This works by allocating a socket to listen to either a TCP
  364. .Ar port
  365. on the local side, optionally bound to the specified
  366. .Ar bind_address ,
  367. or to a Unix socket.
  368. Whenever a connection is made to the local port or socket, the
  369. connection is forwarded over the secure channel, and a connection is
  370. made to either
  371. .Ar host
  372. port
  373. .Ar hostport ,
  374. or the Unix socket
  375. .Ar remote_socket ,
  376. from the remote machine.
  377. .Pp
  378. Port forwardings can also be specified in the configuration file.
  379. Only the superuser can forward privileged ports.
  380. IPv6 addresses can be specified by enclosing the address in square brackets.
  381. .Pp
  382. By default, the local port is bound in accordance with the
  383. .Cm GatewayPorts
  384. setting.
  385. However, an explicit
  386. .Ar bind_address
  387. may be used to bind the connection to a specific address.
  388. The
  389. .Ar bind_address
  390. of
  391. .Dq localhost
  392. indicates that the listening port be bound for local use only, while an
  393. empty address or
  394. .Sq *
  395. indicates that the port should be available from all interfaces.
  396. .Pp
  397. .It Fl l Ar login_name
  398. Specifies the user to log in as on the remote machine.
  399. This also may be specified on a per-host basis in the configuration file.
  400. .Pp
  401. .It Fl M
  402. Places the
  403. .Nm
  404. client into
  405. .Dq master
  406. mode for connection sharing.
  407. Multiple
  408. .Fl M
  409. options places
  410. .Nm
  411. into
  412. .Dq master
  413. mode but with confirmation required using
  414. .Xr ssh-askpass 1
  415. before each operation that changes the multiplexing state
  416. (e.g. opening a new session).
  417. Refer to the description of
  418. .Cm ControlMaster
  419. in
  420. .Xr ssh_config 5
  421. for details.
  422. .Pp
  423. .It Fl m Ar mac_spec
  424. A comma-separated list of MAC (message authentication code) algorithms,
  425. specified in order of preference.
  426. See the
  427. .Cm MACs
  428. keyword for more information.
  429. .Pp
  430. .It Fl N
  431. Do not execute a remote command.
  432. This is useful for just forwarding ports.
  433. Refer to the description of
  434. .Cm NoShell
  435. in
  436. .Xr ssh_config 5
  437. for details.
  438. .Pp
  439. .It Fl n
  440. Redirects stdin from
  441. .Pa /dev/null
  442. (actually, prevents reading from stdin).
  443. This must be used when
  444. .Nm
  445. is run in the background.
  446. A common trick is to use this to run X11 programs on a remote machine.
  447. For example,
  448. .Ic ssh -n shadows.cs.hut.fi emacs &
  449. will start an emacs on shadows.cs.hut.fi, and the X11
  450. connection will be automatically forwarded over an encrypted channel.
  451. The
  452. .Nm
  453. program will be put in the background.
  454. (This does not work if
  455. .Nm
  456. needs to ask for a password or passphrase; see also the
  457. .Fl f
  458. option.)
  459. Refer to the description of
  460. .Cm StdinNull
  461. in
  462. .Xr ssh_config 5
  463. for details.
  464. .Pp
  465. .It Fl O Ar ctl_cmd
  466. Control an active connection multiplexing master process.
  467. When the
  468. .Fl O
  469. option is specified, the
  470. .Ar ctl_cmd
  471. argument is interpreted and passed to the master process.
  472. Valid commands are:
  473. .Dq check
  474. (check that the master process is running),
  475. .Dq forward
  476. (request forwardings without command execution),
  477. .Dq cancel
  478. (cancel forwardings),
  479. .Dq exit
  480. (request the master to exit), and
  481. .Dq stop
  482. (request the master to stop accepting further multiplexing requests).
  483. .Pp
  484. .It Fl o Ar option
  485. Can be used to give options in the format used in the configuration file.
  486. This is useful for specifying options for which there is no separate
  487. command-line flag.
  488. For full details of the options listed below, and their possible values, see
  489. .Xr ssh_config 5 .
  490. .Pp
  491. .Bl -tag -width Ds -offset indent -compact
  492. .It AddKeysToAgent
  493. .It AddressFamily
  494. .It BatchMode
  495. .It BindAddress
  496. .It CanonicalDomains
  497. .It CanonicalizeFallbackLocal
  498. .It CanonicalizeHostname
  499. .It CanonicalizeMaxDots
  500. .It CanonicalizePermittedCNAMEs
  501. .It CASignatureAlgorithms
  502. .It CertificateFile
  503. .It ChallengeResponseAuthentication
  504. .It CheckHostIP
  505. .It Ciphers
  506. .It ClearAllForwardings
  507. .It Compression
  508. .It ConnectionAttempts
  509. .It ConnectTimeout
  510. .It ControlMaster
  511. .It ControlPath
  512. .It ControlPersist
  513. .It DynamicForward
  514. .It EscapeChar
  515. .It ExitOnForwardFailure
  516. .It FingerprintHash
  517. .It ForwardAgent
  518. .It ForwardX11
  519. .It ForwardX11Timeout
  520. .It ForwardX11Trusted
  521. .It GatewayPorts
  522. .It GlobalKnownHostsFile
  523. .It GSSAPIAuthentication
  524. .It GSSAPIDelegateCredentials
  525. .It HashKnownHosts
  526. .It Host
  527. .It HostbasedAcceptedAlgorithms
  528. .It HostbasedAuthentication
  529. .It HostKeyAlgorithms
  530. .It HostKeyAlias
  531. .It Hostname
  532. .It IdentitiesOnly
  533. .It IdentityAgent
  534. .It IdentityFile
  535. .It IPQoS
  536. .It KbdInteractiveAuthentication
  537. .It KbdInteractiveDevices
  538. .It KexAlgorithms
  539. .It LocalCommand
  540. .It LocalForward
  541. .It LogLevel
  542. .It MACs
  543. .It Match
  544. .It NoHostAuthenticationForLocalhost
  545. .It NumberOfPasswordPrompts
  546. .It PasswordAuthentication
  547. .It PermitLocalCommand
  548. .It PermitRemoteOpen
  549. .It PKCS11Provider
  550. .It Port
  551. .It PreferredAuthentications
  552. .It ProxyCommand
  553. .It ProxyJump
  554. .It ProxyUseFdpass
  555. .It PubkeyAcceptedAlgorithms
  556. .It PubkeyAuthentication
  557. .It RekeyLimit
  558. .It RemoteCommand
  559. .It RemoteForward
  560. .It RequestTTY
  561. .It SendEnv
  562. .It ServerAliveInterval
  563. .It ServerAliveCountMax
  564. .It SetEnv
  565. .It StreamLocalBindMask
  566. .It StreamLocalBindUnlink
  567. .It StrictHostKeyChecking
  568. .It TCPKeepAlive
  569. .It Tunnel
  570. .It TunnelDevice
  571. .It UpdateHostKeys
  572. .It User
  573. .It UserKnownHostsFile
  574. .It VerifyHostKeyDNS
  575. .It VisualHostKey
  576. .It XAuthLocation
  577. .El
  578. .Pp
  579. .It Fl p Ar port
  580. Port to connect to on the remote host.
  581. This can be specified on a
  582. per-host basis in the configuration file.
  583. .Pp
  584. .It Fl Q Ar query_option
  585. Queries
  586. .Nm
  587. for the algorithms supported for the specified version 2.
  588. The available features are:
  589. .Ar cipher
  590. (supported symmetric ciphers),
  591. .Ar cipher-auth
  592. (supported symmetric ciphers that support authenticated encryption),
  593. .Ar help
  594. (supported query terms for use with the
  595. .Fl Q
  596. flag),
  597. .Ar mac
  598. (supported message integrity codes),
  599. .Ar kex
  600. (key exchange algorithms),
  601. .Ar key
  602. (key types),
  603. .Ar key-cert
  604. (certificate key types),
  605. .Ar key-plain
  606. (non-certificate key types),
  607. .Ar key-sig
  608. (all key types and signature algorithms),
  609. .Ar protocol-version
  610. (supported SSH protocol versions), and
  611. .Ar sig
  612. (supported signature algorithms).
  613. Alternatively, any keyword from
  614. .Xr ssh_config 5
  615. or
  616. .Xr sshd_config 5
  617. that takes an algorithm list may be used as an alias for the corresponding
  618. query_option.
  619. .Pp
  620. .It Fl q
  621. Quiet mode.
  622. Causes most warning and diagnostic messages to be suppressed.
  623. .Pp
  624. .It Fl R Xo
  625. .Sm off
  626. .Oo Ar bind_address : Oc
  627. .Ar port : host : hostport
  628. .Sm on
  629. .Xc
  630. .It Fl R Xo
  631. .Sm off
  632. .Oo Ar bind_address : Oc
  633. .Ar port : local_socket
  634. .Sm on
  635. .Xc
  636. .It Fl R Xo
  637. .Sm off
  638. .Ar remote_socket : host : hostport
  639. .Sm on
  640. .Xc
  641. .It Fl R Xo
  642. .Sm off
  643. .Ar remote_socket : local_socket
  644. .Sm on
  645. .Xc
  646. .It Fl R Xo
  647. .Sm off
  648. .Oo Ar bind_address : Oc
  649. .Ar port
  650. .Sm on
  651. .Xc
  652. Specifies that connections to the given TCP port or Unix socket on the remote
  653. (server) host are to be forwarded to the local side.
  654. .Pp
  655. This works by allocating a socket to listen to either a TCP
  656. .Ar port
  657. or to a Unix socket on the remote side.
  658. Whenever a connection is made to this port or Unix socket, the
  659. connection is forwarded over the secure channel, and a connection
  660. is made from the local machine to either an explicit destination specified by
  661. .Ar host
  662. port
  663. .Ar hostport ,
  664. or
  665. .Ar local_socket ,
  666. or, if no explicit destination was specified,
  667. .Nm
  668. will act as a SOCKS 4/5 proxy and forward connections to the destinations
  669. requested by the remote SOCKS client.
  670. .Pp
  671. Port forwardings can also be specified in the configuration file.
  672. Privileged ports can be forwarded only when
  673. logging in as root on the remote machine.
  674. IPv6 addresses can be specified by enclosing the address in square brackets.
  675. .Pp
  676. By default, TCP listening sockets on the server will be bound to the loopback
  677. interface only.
  678. This may be overridden by specifying a
  679. .Ar bind_address .
  680. An empty
  681. .Ar bind_address ,
  682. or the address
  683. .Ql * ,
  684. indicates that the remote socket should listen on all interfaces.
  685. Specifying a remote
  686. .Ar bind_address
  687. will only succeed if the server's
  688. .Cm GatewayPorts
  689. option is enabled (see
  690. .Xr sshd_config 5 ) .
  691. .Pp
  692. If the
  693. .Ar port
  694. argument is
  695. .Ql 0 ,
  696. the listen port will be dynamically allocated on the server and reported
  697. to the client at run time.
  698. When used together with
  699. .Ic -O forward
  700. the allocated port will be printed to the standard output.
  701. .Pp
  702. .It Fl S Ar ctl_path
  703. Specifies the location of a control socket for connection sharing,
  704. or the string
  705. .Dq none
  706. to disable connection sharing.
  707. Refer to the description of
  708. .Cm ControlPath
  709. and
  710. .Cm ControlMaster
  711. in
  712. .Xr ssh_config 5
  713. for details.
  714. .Pp
  715. .It Fl s
  716. May be used to request invocation of a subsystem on the remote system.
  717. Subsystems facilitate the use of SSH
  718. as a secure transport for other applications (e.g.\&
  719. .Xr sftp 1 ) .
  720. The subsystem is specified as the remote command.
  721. .Pp
  722. .It Fl T
  723. Disable pseudo-terminal allocation.
  724. .Pp
  725. .It Fl t
  726. Force pseudo-terminal allocation.
  727. This can be used to execute arbitrary
  728. screen-based programs on a remote machine, which can be very useful,
  729. e.g. when implementing menu services.
  730. Multiple
  731. .Fl t
  732. options force tty allocation, even if
  733. .Nm
  734. has no local tty.
  735. .Pp
  736. .It Fl V
  737. Display the version number and exit.
  738. .Pp
  739. .It Fl v
  740. Verbose mode.
  741. Causes
  742. .Nm
  743. to print debugging messages about its progress.
  744. This is helpful in
  745. debugging connection, authentication, and configuration problems.
  746. Multiple
  747. .Fl v
  748. options increase the verbosity.
  749. The maximum is 3.
  750. .Pp
  751. .It Fl W Ar host : Ns Ar port
  752. Requests that standard input and output on the client be forwarded to
  753. .Ar host
  754. on
  755. .Ar port
  756. over the secure channel.
  757. Implies
  758. .Fl N ,
  759. .Fl T ,
  760. .Cm ExitOnForwardFailure
  761. and
  762. .Cm ClearAllForwardings ,
  763. though these can be overridden in the configuration file or using
  764. .Fl o
  765. command line options.
  766. .Pp
  767. .It Fl w Xo
  768. .Ar local_tun Ns Op : Ns Ar remote_tun
  769. .Xc
  770. Requests
  771. tunnel
  772. device forwarding with the specified
  773. .Xr tun 4
  774. devices between the client
  775. .Pq Ar local_tun
  776. and the server
  777. .Pq Ar remote_tun .
  778. .Pp
  779. The devices may be specified by numerical ID or the keyword
  780. .Dq any ,
  781. which uses the next available tunnel device.
  782. If
  783. .Ar remote_tun
  784. is not specified, it defaults to
  785. .Dq any .
  786. See also the
  787. .Cm Tunnel
  788. and
  789. .Cm TunnelDevice
  790. directives in
  791. .Xr ssh_config 5 .
  792. .Pp
  793. If the
  794. .Cm Tunnel
  795. directive is unset, it will be set to the default tunnel mode, which is
  796. .Dq point-to-point .
  797. If a different
  798. .Cm Tunnel
  799. forwarding mode it desired, then it should be specified before
  800. .Fl w .
  801. .Pp
  802. .It Fl X
  803. Enables X11 forwarding.
  804. This can also be specified on a per-host basis in a configuration file.
  805. .Pp
  806. X11 forwarding should be enabled with caution.
  807. Users with the ability to bypass file permissions on the remote host
  808. (for the user's X authorization database)
  809. can access the local X11 display through the forwarded connection.
  810. An attacker may then be able to perform activities such as keystroke monitoring.
  811. .Pp
  812. For this reason, X11 forwarding is subjected to X11 SECURITY extension
  813. restrictions by default.
  814. Please refer to the
  815. .Nm
  816. .Fl Y
  817. option and the
  818. .Cm ForwardX11Trusted
  819. directive in
  820. .Xr ssh_config 5
  821. for more information.
  822. .Pp
  823. .It Fl x
  824. Disables X11 forwarding.
  825. .Pp
  826. .It Fl Y
  827. Enables trusted X11 forwarding.
  828. Trusted X11 forwardings are not subjected to the X11 SECURITY extension
  829. controls.
  830. .Pp
  831. .It Fl y
  832. Send log information using the
  833. .Xr syslog 3
  834. system module.
  835. By default this information is sent to stderr.
  836. .El
  837. .Pp
  838. .Nm
  839. may additionally obtain configuration data from
  840. a per-user configuration file and a system-wide configuration file.
  841. The file format and configuration options are described in
  842. .Xr ssh_config 5 .
  843. .Sh AUTHENTICATION
  844. The OpenSSH SSH client supports SSH protocol 2.
  845. .Pp
  846. The methods available for authentication are:
  847. GSSAPI-based authentication,
  848. host-based authentication,
  849. public key authentication,
  850. challenge-response authentication,
  851. and password authentication.
  852. Authentication methods are tried in the order specified above,
  853. though
  854. .Cm PreferredAuthentications
  855. can be used to change the default order.
  856. .Pp
  857. Host-based authentication works as follows:
  858. If the machine the user logs in from is listed in
  859. .Pa /etc/hosts.equiv
  860. or
  861. .Pa /etc/shosts.equiv
  862. on the remote machine, the user is non-root and the user names are
  863. the same on both sides, or if the files
  864. .Pa ~/.rhosts
  865. or
  866. .Pa ~/.shosts
  867. exist in the user's home directory on the
  868. remote machine and contain a line containing the name of the client
  869. machine and the name of the user on that machine, the user is
  870. considered for login.
  871. Additionally, the server
  872. .Em must
  873. be able to verify the client's
  874. host key (see the description of
  875. .Pa /etc/ssh/ssh_known_hosts
  876. and
  877. .Pa ~/.ssh/known_hosts ,
  878. below)
  879. for login to be permitted.
  880. This authentication method closes security holes due to IP
  881. spoofing, DNS spoofing, and routing spoofing.
  882. [Note to the administrator:
  883. .Pa /etc/hosts.equiv ,
  884. .Pa ~/.rhosts ,
  885. and the rlogin/rsh protocol in general, are inherently insecure and should be
  886. disabled if security is desired.]
  887. .Pp
  888. Public key authentication works as follows:
  889. The scheme is based on public-key cryptography,
  890. using cryptosystems
  891. where encryption and decryption are done using separate keys,
  892. and it is unfeasible to derive the decryption key from the encryption key.
  893. The idea is that each user creates a public/private
  894. key pair for authentication purposes.
  895. The server knows the public key, and only the user knows the private key.
  896. .Nm
  897. implements public key authentication protocol automatically,
  898. using one of the DSA, ECDSA, Ed25519 or RSA algorithms.
  899. The HISTORY section of
  900. .Xr ssl 8
  901. (on non-OpenBSD systems, see
  902. .nh
  903. http://www.openbsd.org/cgi\-bin/man.cgi?query=ssl&sektion=8#HISTORY)
  904. .hy
  905. contains a brief discussion of the DSA and RSA algorithms.
  906. .Pp
  907. The file
  908. .Pa ~/.ssh/authorized_keys
  909. lists the public keys that are permitted for logging in.
  910. When the user logs in, the
  911. .Nm
  912. program tells the server which key pair it would like to use for
  913. authentication.
  914. The client proves that it has access to the private key
  915. and the server checks that the corresponding public key
  916. is authorized to accept the account.
  917. .Pp
  918. The server may inform the client of errors that prevented public key
  919. authentication from succeeding after authentication completes using a
  920. different method.
  921. These may be viewed by increasing the
  922. .Cm LogLevel
  923. to
  924. .Cm DEBUG
  925. or higher (e.g. by using the
  926. .Fl v
  927. flag).
  928. .Pp
  929. The user creates his/her key pair by running
  930. .Xr ssh-keygen 1 .
  931. This stores the private key in
  932. .Pa ~/.ssh/id_dsa
  933. (DSA),
  934. .Pa ~/.ssh/id_ecdsa
  935. (ECDSA),
  936. .Pa ~/.ssh/id_ecdsa_sk
  937. (authenticator-hosted ECDSA),
  938. .Pa ~/.ssh/id_ed25519
  939. (Ed25519),
  940. .Pa ~/.ssh/id_ed25519_sk
  941. (authenticator-hosted Ed25519),
  942. or
  943. .Pa ~/.ssh/id_rsa
  944. (RSA)
  945. and stores the public key in
  946. .Pa ~/.ssh/id_dsa.pub
  947. (DSA),
  948. .Pa ~/.ssh/id_ecdsa.pub
  949. (ECDSA),
  950. .Pa ~/.ssh/id_ecdsa_sk.pub
  951. (authenticator-hosted ECDSA),
  952. .Pa ~/.ssh/id_ed25519.pub
  953. (Ed25519),
  954. .Pa ~/.ssh/id_ed25519_sk.pub
  955. (authenticator-hosted Ed25519),
  956. or
  957. .Pa ~/.ssh/id_rsa.pub
  958. (RSA)
  959. in the user's home directory.
  960. The user should then copy the public key
  961. to
  962. .Pa ~/.ssh/authorized_keys
  963. in his/her home directory on the remote machine.
  964. The
  965. .Pa authorized_keys
  966. file corresponds to the conventional
  967. .Pa ~/.rhosts
  968. file, and has one key
  969. per line, though the lines can be very long.
  970. After this, the user can log in without giving the password.
  971. .Pp
  972. A variation on public key authentication
  973. is available in the form of certificate authentication:
  974. instead of a set of public/private keys,
  975. signed certificates are used.
  976. This has the advantage that a single trusted certification authority
  977. can be used in place of many public/private keys.
  978. See the CERTIFICATES section of
  979. .Xr ssh-keygen 1
  980. for more information.
  981. .Pp
  982. The most convenient way to use public key or certificate authentication
  983. may be with an authentication agent.
  984. See
  985. .Xr ssh-agent 1
  986. and (optionally) the
  987. .Cm AddKeysToAgent
  988. directive in
  989. .Xr ssh_config 5
  990. for more information.
  991. .Pp
  992. Challenge-response authentication works as follows:
  993. The server sends an arbitrary
  994. .Qq challenge
  995. text, and prompts for a response.
  996. Examples of challenge-response authentication include
  997. .Bx
  998. Authentication (see
  999. .Xr login.conf 5 )
  1000. and PAM (some
  1001. .Pf non- Ox
  1002. systems).
  1003. .Pp
  1004. Finally, if other authentication methods fail,
  1005. .Nm
  1006. prompts the user for a password.
  1007. The password is sent to the remote
  1008. host for checking; however, since all communications are encrypted,
  1009. the password cannot be seen by someone listening on the network.
  1010. .Pp
  1011. .Nm
  1012. automatically maintains and checks a database containing
  1013. identification for all hosts it has ever been used with.
  1014. Host keys are stored in
  1015. .Pa ~/.ssh/known_hosts
  1016. in the user's home directory.
  1017. Additionally, the file
  1018. .Pa /etc/ssh/ssh_known_hosts
  1019. is automatically checked for known hosts.
  1020. Any new hosts are automatically added to the user's file.
  1021. If a host's identification ever changes,
  1022. .Nm
  1023. warns about this and disables password authentication to prevent
  1024. server spoofing or man-in-the-middle attacks,
  1025. which could otherwise be used to circumvent the encryption.
  1026. The
  1027. .Cm StrictHostKeyChecking
  1028. option can be used to control logins to machines whose
  1029. host key is not known or has changed.
  1030. .Pp
  1031. When the user's identity has been accepted by the server, the server
  1032. either executes the given command in a non-interactive session or,
  1033. if no command has been specified, logs into the machine and gives
  1034. the user a normal shell as an interactive session.
  1035. All communication with
  1036. the remote command or shell will be automatically encrypted.
  1037. .Pp
  1038. If an interactive session is requested
  1039. .Nm
  1040. by default will only request a pseudo-terminal (pty) for interactive
  1041. sessions when the client has one.
  1042. The flags
  1043. .Fl T
  1044. and
  1045. .Fl t
  1046. can be used to override this behaviour.
  1047. .Pp
  1048. If a pseudo-terminal has been allocated the
  1049. user may use the escape characters noted below.
  1050. .Pp
  1051. If no pseudo-terminal has been allocated,
  1052. the session is transparent and can be used to reliably transfer binary data.
  1053. On most systems, setting the escape character to
  1054. .Dq none
  1055. will also make the session transparent even if a tty is used.
  1056. .Pp
  1057. The session terminates when the command or shell on the remote
  1058. machine exits and all X11 and TCP connections have been closed.
  1059. .Sh ESCAPE CHARACTERS
  1060. When a pseudo-terminal has been requested,
  1061. .Nm
  1062. supports a number of functions through the use of an escape character.
  1063. .Pp
  1064. A single tilde character can be sent as
  1065. .Ic ~~
  1066. or by following the tilde by a character other than those described below.
  1067. The escape character must always follow a newline to be interpreted as
  1068. special.
  1069. The escape character can be changed in configuration files using the
  1070. .Cm EscapeChar
  1071. configuration directive or on the command line by the
  1072. .Fl e
  1073. option.
  1074. .Pp
  1075. The supported escapes (assuming the default
  1076. .Ql ~ )
  1077. are:
  1078. .Bl -tag -width Ds
  1079. .It Cm ~.
  1080. Disconnect.
  1081. .It Cm ~^Z
  1082. Background
  1083. .Nm .
  1084. .It Cm ~#
  1085. List forwarded connections.
  1086. .It Cm ~&
  1087. Background
  1088. .Nm
  1089. at logout when waiting for forwarded connection / X11 sessions to terminate.
  1090. .It Cm ~?
  1091. Display a list of escape characters.
  1092. .It Cm ~B
  1093. Send a BREAK to the remote system
  1094. (only useful if the peer supports it).
  1095. .It Cm ~C
  1096. Open command line.
  1097. Currently this allows the addition of port forwardings using the
  1098. .Fl L ,
  1099. .Fl R
  1100. and
  1101. .Fl D
  1102. options (see above).
  1103. It also allows the cancellation of existing port-forwardings
  1104. with
  1105. .Sm off
  1106. .Fl KL Oo Ar bind_address : Oc Ar port
  1107. .Sm on
  1108. for local,
  1109. .Sm off
  1110. .Fl KR Oo Ar bind_address : Oc Ar port
  1111. .Sm on
  1112. for remote and
  1113. .Sm off
  1114. .Fl KD Oo Ar bind_address : Oc Ar port
  1115. .Sm on
  1116. for dynamic port-forwardings.
  1117. .Ic !\& Ns Ar command
  1118. allows the user to execute a local command if the
  1119. .Ic PermitLocalCommand
  1120. option is enabled in
  1121. .Xr ssh_config 5 .
  1122. Basic help is available, using the
  1123. .Fl h
  1124. option.
  1125. .It Cm ~R
  1126. Request rekeying of the connection
  1127. (only useful if the peer supports it).
  1128. .It Cm ~V
  1129. Decrease the verbosity
  1130. .Pq Ic LogLevel
  1131. when errors are being written to stderr.
  1132. .It Cm ~v
  1133. Increase the verbosity
  1134. .Pq Ic LogLevel
  1135. when errors are being written to stderr.
  1136. .El
  1137. .Sh TCP FORWARDING
  1138. Forwarding of arbitrary TCP connections over a secure channel
  1139. can be specified either on the command line or in a configuration file.
  1140. One possible application of TCP forwarding is a secure connection to a
  1141. mail server; another is going through firewalls.
  1142. .Pp
  1143. In the example below, we look at encrypting communication for an IRC client,
  1144. even though the IRC server it connects to does not directly
  1145. support encrypted communication.
  1146. This works as follows:
  1147. the user connects to the remote host using
  1148. .Nm ,
  1149. specifying the ports to be used to forward the connection.
  1150. After that it is possible to start the program locally,
  1151. and
  1152. .Nm
  1153. will encrypt and forward the connection to the remote server.
  1154. .Pp
  1155. The following example tunnels an IRC session from the client
  1156. to an IRC server at
  1157. .Dq server.example.com ,
  1158. joining channel
  1159. .Dq #users ,
  1160. nickname
  1161. .Dq pinky ,
  1162. using the standard IRC port, 6667:
  1163. .Bd -literal -offset 4n
  1164. $ ssh -f -L 6667:localhost:6667 server.example.com sleep 10
  1165. $ irc -c '#users' pinky IRC/127.0.0.1
  1166. .Ed
  1167. .Pp
  1168. The
  1169. .Fl f
  1170. option backgrounds
  1171. .Nm
  1172. and the remote command
  1173. .Dq sleep 10
  1174. is specified to allow an amount of time
  1175. (10 seconds, in the example)
  1176. to start the program which is going to use the tunnel.
  1177. If no connections are made within the time specified,
  1178. .Nm
  1179. will exit.
  1180. .Sh X11 FORWARDING
  1181. If the
  1182. .Cm ForwardX11
  1183. variable is set to
  1184. .Dq yes
  1185. (or see the description of the
  1186. .Fl X ,
  1187. .Fl x ,
  1188. and
  1189. .Fl Y
  1190. options above)
  1191. and the user is using X11 (the
  1192. .Ev DISPLAY
  1193. environment variable is set), the connection to the X11 display is
  1194. automatically forwarded to the remote side in such a way that any X11
  1195. programs started from the shell (or command) will go through the
  1196. encrypted channel, and the connection to the real X server will be made
  1197. from the local machine.
  1198. The user should not manually set
  1199. .Ev DISPLAY .
  1200. Forwarding of X11 connections can be
  1201. configured on the command line or in configuration files.
  1202. .Pp
  1203. The
  1204. .Ev DISPLAY
  1205. value set by
  1206. .Nm
  1207. will point to the server machine, but with a display number greater than zero.
  1208. This is normal, and happens because
  1209. .Nm
  1210. creates a
  1211. .Dq proxy
  1212. X server on the server machine for forwarding the
  1213. connections over the encrypted channel.
  1214. .Pp
  1215. .Nm
  1216. will also automatically set up Xauthority data on the server machine.
  1217. For this purpose, it will generate a random authorization cookie,
  1218. store it in Xauthority on the server, and verify that any forwarded
  1219. connections carry this cookie and replace it by the real cookie when
  1220. the connection is opened.
  1221. The real authentication cookie is never
  1222. sent to the server machine (and no cookies are sent in the plain).
  1223. .Pp
  1224. If the
  1225. .Cm ForwardAgent
  1226. variable is set to
  1227. .Dq yes
  1228. (or see the description of the
  1229. .Fl A
  1230. and
  1231. .Fl a
  1232. options above) and
  1233. the user is using an authentication agent, the connection to the agent
  1234. is automatically forwarded to the remote side.
  1235. .Sh VERIFYING HOST KEYS
  1236. When connecting to a server for the first time,
  1237. a fingerprint of the server's public key is presented to the user
  1238. (unless the option
  1239. .Cm StrictHostKeyChecking
  1240. has been disabled).
  1241. Fingerprints can be determined using
  1242. .Xr ssh-keygen 1 :
  1243. .Pp
  1244. .Dl $ ssh-keygen -l -f /etc/ssh/ssh_host_rsa_key
  1245. .Pp
  1246. If the fingerprint is already known, it can be matched
  1247. and the key can be accepted or rejected.
  1248. If only legacy (MD5) fingerprints for the server are available, the
  1249. .Xr ssh-keygen 1
  1250. .Fl E
  1251. option may be used to downgrade the fingerprint algorithm to match.
  1252. .Pp
  1253. Because of the difficulty of comparing host keys
  1254. just by looking at fingerprint strings,
  1255. there is also support to compare host keys visually,
  1256. using
  1257. .Em random art .
  1258. By setting the
  1259. .Cm VisualHostKey
  1260. option to
  1261. .Dq yes ,
  1262. a small ASCII graphic gets displayed on every login to a server, no matter
  1263. if the session itself is interactive or not.
  1264. By learning the pattern a known server produces, a user can easily
  1265. find out that the host key has changed when a completely different pattern
  1266. is displayed.
  1267. Because these patterns are not unambiguous however, a pattern that looks
  1268. similar to the pattern remembered only gives a good probability that the
  1269. host key is the same, not guaranteed proof.
  1270. .Pp
  1271. To get a listing of the fingerprints along with their random art for
  1272. all known hosts, the following command line can be used:
  1273. .Pp
  1274. .Dl $ ssh-keygen -lv -f ~/.ssh/known_hosts
  1275. .Pp
  1276. If the fingerprint is unknown,
  1277. an alternative method of verification is available:
  1278. SSH fingerprints verified by DNS.
  1279. An additional resource record (RR),
  1280. SSHFP,
  1281. is added to a zonefile
  1282. and the connecting client is able to match the fingerprint
  1283. with that of the key presented.
  1284. .Pp
  1285. In this example, we are connecting a client to a server,
  1286. .Dq host.example.com .
  1287. The SSHFP resource records should first be added to the zonefile for
  1288. host.example.com:
  1289. .Bd -literal -offset indent
  1290. $ ssh-keygen -r host.example.com.
  1291. .Ed
  1292. .Pp
  1293. The output lines will have to be added to the zonefile.
  1294. To check that the zone is answering fingerprint queries:
  1295. .Pp
  1296. .Dl $ dig -t SSHFP host.example.com
  1297. .Pp
  1298. Finally the client connects:
  1299. .Bd -literal -offset indent
  1300. $ ssh -o "VerifyHostKeyDNS ask" host.example.com
  1301. [...]
  1302. Matching host key fingerprint found in DNS.
  1303. Are you sure you want to continue connecting (yes/no)?
  1304. .Ed
  1305. .Pp
  1306. See the
  1307. .Cm VerifyHostKeyDNS
  1308. option in
  1309. .Xr ssh_config 5
  1310. for more information.
  1311. .Sh SSH-BASED VIRTUAL PRIVATE NETWORKS
  1312. .Nm
  1313. contains support for Virtual Private Network (VPN) tunnelling
  1314. using the
  1315. .Xr tun 4
  1316. network pseudo-device,
  1317. allowing two networks to be joined securely.
  1318. The
  1319. .Xr sshd_config 5
  1320. configuration option
  1321. .Cm PermitTunnel
  1322. controls whether the server supports this,
  1323. and at what level (layer 2 or 3 traffic).
  1324. .Pp
  1325. The following example would connect client network 10.0.50.0/24
  1326. with remote network 10.0.99.0/24 using a point-to-point connection
  1327. from 10.1.1.1 to 10.1.1.2,
  1328. provided that the SSH server running on the gateway to the remote network,
  1329. at 192.168.1.15, allows it.
  1330. .Pp
  1331. On the client:
  1332. .Bd -literal -offset indent
  1333. # ssh -f -w 0:1 192.168.1.15 true
  1334. # ifconfig tun0 10.1.1.1 10.1.1.2 netmask 255.255.255.252
  1335. # route add 10.0.99.0/24 10.1.1.2
  1336. .Ed
  1337. .Pp
  1338. On the server:
  1339. .Bd -literal -offset indent
  1340. # ifconfig tun1 10.1.1.2 10.1.1.1 netmask 255.255.255.252
  1341. # route add 10.0.50.0/24 10.1.1.1
  1342. .Ed
  1343. .Pp
  1344. Client access may be more finely tuned via the
  1345. .Pa /root/.ssh/authorized_keys
  1346. file (see below) and the
  1347. .Cm PermitRootLogin
  1348. server option.
  1349. The following entry would permit connections on
  1350. .Xr tun 4
  1351. device 1 from user
  1352. .Dq jane
  1353. and on tun device 2 from user
  1354. .Dq john ,
  1355. if
  1356. .Cm PermitRootLogin
  1357. is set to
  1358. .Dq forced-commands-only :
  1359. .Bd -literal -offset 2n
  1360. tunnel="1",command="sh /etc/netstart tun1" ssh-rsa ... jane
  1361. tunnel="2",command="sh /etc/netstart tun2" ssh-rsa ... john
  1362. .Ed
  1363. .Pp
  1364. Since an SSH-based setup entails a fair amount of overhead,
  1365. it may be more suited to temporary setups,
  1366. such as for wireless VPNs.
  1367. More permanent VPNs are better provided by tools such as
  1368. .Xr ipsecctl 8
  1369. and
  1370. .Xr isakmpd 8 .
  1371. .Sh ENVIRONMENT
  1372. .Nm
  1373. will normally set the following environment variables:
  1374. .Bl -tag -width "SSH_ORIGINAL_COMMAND"
  1375. .It Ev DISPLAY
  1376. The
  1377. .Ev DISPLAY
  1378. variable indicates the location of the X11 server.
  1379. It is automatically set by
  1380. .Nm
  1381. to point to a value of the form
  1382. .Dq hostname:n ,
  1383. where
  1384. .Dq hostname
  1385. indicates the host where the shell runs, and
  1386. .Sq n
  1387. is an integer \*(Ge 1.
  1388. .Nm
  1389. uses this special value to forward X11 connections over the secure
  1390. channel.
  1391. The user should normally not set
  1392. .Ev DISPLAY
  1393. explicitly, as that
  1394. will render the X11 connection insecure (and will require the user to
  1395. manually copy any required authorization cookies).
  1396. .It Ev HOME
  1397. Set to the path of the user's home directory.
  1398. .It Ev LOGNAME
  1399. Synonym for
  1400. .Ev USER ;
  1401. set for compatibility with systems that use this variable.
  1402. .It Ev MAIL
  1403. Set to the path of the user's mailbox.
  1404. .It Ev PATH
  1405. Set to the default
  1406. .Ev PATH ,
  1407. as specified when compiling
  1408. .Nm .
  1409. .It Ev SSH_ASKPASS
  1410. If
  1411. .Nm
  1412. needs a passphrase, it will read the passphrase from the current
  1413. terminal if it was run from a terminal.
  1414. If
  1415. .Nm
  1416. does not have a terminal associated with it but
  1417. .Ev DISPLAY
  1418. and
  1419. .Ev SSH_ASKPASS
  1420. are set, it will execute the program specified by
  1421. .Ev SSH_ASKPASS
  1422. and open an X11 window to read the passphrase.
  1423. This is particularly useful when calling
  1424. .Nm
  1425. from a
  1426. .Pa .xsession
  1427. or related script.
  1428. (Note that on some machines it
  1429. may be necessary to redirect the input from
  1430. .Pa /dev/null
  1431. to make this work.)
  1432. .It Ev SSH_ASKPASS_REQUIRE
  1433. Allows further control over the use of an askpass program.
  1434. If this variable is set to
  1435. .Dq never
  1436. then
  1437. .Nm
  1438. will never attempt to use one.
  1439. If it is set to
  1440. .Dq prefer ,
  1441. then
  1442. .Nm
  1443. will prefer to use the askpass program instead of the TTY when requesting
  1444. passwords.
  1445. Finally, if the variable is set to
  1446. .Dq force ,
  1447. then the askpass program will be used for all passphrase input regardless
  1448. of whether
  1449. .Ev DISPLAY
  1450. is set.
  1451. .It Ev SSH_AUTH_SOCK
  1452. Identifies the path of a
  1453. .Ux Ns -domain
  1454. socket used to communicate with the agent.
  1455. .It Ev SSH_CONNECTION
  1456. Identifies the client and server ends of the connection.
  1457. The variable contains
  1458. four space-separated values: client IP address, client port number,
  1459. server IP address, and server port number.
  1460. .It Ev SSH_ORIGINAL_COMMAND
  1461. This variable contains the original command line if a forced command
  1462. is executed.
  1463. It can be used to extract the original arguments.
  1464. .It Ev SSH_TTY
  1465. This is set to the name of the tty (path to the device) associated
  1466. with the current shell or command.
  1467. If the current session has no tty,
  1468. this variable is not set.
  1469. .It Ev SSH_TUNNEL
  1470. Optionally set by
  1471. .Xr sshd 8
  1472. to contain the interface names assigned if tunnel forwarding was
  1473. requested by the client.
  1474. .It Ev SSH_USER_AUTH
  1475. Optionally set by
  1476. .Xr sshd 8 ,
  1477. this variable may contain a pathname to a file that lists the authentication
  1478. methods successfully used when the session was established, including any
  1479. public keys that were used.
  1480. .It Ev TZ
  1481. This variable is set to indicate the present time zone if it
  1482. was set when the daemon was started (i.e. the daemon passes the value
  1483. on to new connections).
  1484. .It Ev USER
  1485. Set to the name of the user logging in.
  1486. .El
  1487. .Pp
  1488. Additionally,
  1489. .Nm
  1490. reads
  1491. .Pa ~/.ssh/environment ,
  1492. and adds lines of the format
  1493. .Dq VARNAME=value
  1494. to the environment if the file exists and users are allowed to
  1495. change their environment.
  1496. For more information, see the
  1497. .Cm PermitUserEnvironment
  1498. option in
  1499. .Xr sshd_config 5 .
  1500. .Sh FILES
  1501. .Bl -tag -width Ds -compact
  1502. .It Pa ~/.rhosts
  1503. This file is used for host-based authentication (see above).
  1504. On some machines this file may need to be
  1505. world-readable if the user's home directory is on an NFS partition,
  1506. because
  1507. .Xr sshd 8
  1508. reads it as root.
  1509. Additionally, this file must be owned by the user,
  1510. and must not have write permissions for anyone else.
  1511. The recommended
  1512. permission for most machines is read/write for the user, and not
  1513. accessible by others.
  1514. .Pp
  1515. .It Pa ~/.shosts
  1516. This file is used in exactly the same way as
  1517. .Pa .rhosts ,
  1518. but allows host-based authentication without permitting login with
  1519. rlogin/rsh.
  1520. .Pp
  1521. .It Pa ~/.ssh/
  1522. This directory is the default location for all user-specific configuration
  1523. and authentication information.
  1524. There is no general requirement to keep the entire contents of this directory
  1525. secret, but the recommended permissions are read/write/execute for the user,
  1526. and not accessible by others.
  1527. .Pp
  1528. .It Pa ~/.ssh/authorized_keys
  1529. Lists the public keys (DSA, ECDSA, Ed25519, RSA)
  1530. that can be used for logging in as this user.
  1531. The format of this file is described in the
  1532. .Xr sshd 8
  1533. manual page.
  1534. This file is not highly sensitive, but the recommended
  1535. permissions are read/write for the user, and not accessible by others.
  1536. .Pp
  1537. .It Pa ~/.ssh/config
  1538. This is the per-user configuration file.
  1539. The file format and configuration options are described in
  1540. .Xr ssh_config 5 .
  1541. Because of the potential for abuse, this file must have strict permissions:
  1542. read/write for the user, and not writable by others.
  1543. .Pp
  1544. .It Pa ~/.ssh/environment
  1545. Contains additional definitions for environment variables; see
  1546. .Sx ENVIRONMENT ,
  1547. above.
  1548. .Pp
  1549. .It Pa ~/.ssh/id_dsa
  1550. .It Pa ~/.ssh/id_ecdsa
  1551. .It Pa ~/.ssh/id_ecdsa_sk
  1552. .It Pa ~/.ssh/id_ed25519
  1553. .It Pa ~/.ssh/id_ed25519_sk
  1554. .It Pa ~/.ssh/id_rsa
  1555. Contains the private key for authentication.
  1556. These files
  1557. contain sensitive data and should be readable by the user but not
  1558. accessible by others (read/write/execute).
  1559. .Nm
  1560. will simply ignore a private key file if it is accessible by others.
  1561. It is possible to specify a passphrase when
  1562. generating the key which will be used to encrypt the
  1563. sensitive part of this file using AES-128.
  1564. .Pp
  1565. .It Pa ~/.ssh/id_dsa.pub
  1566. .It Pa ~/.ssh/id_ecdsa.pub
  1567. .It Pa ~/.ssh/id_ecdsa_sk.pub
  1568. .It Pa ~/.ssh/id_ed25519.pub
  1569. .It Pa ~/.ssh/id_ed25519_sk.pub
  1570. .It Pa ~/.ssh/id_rsa.pub
  1571. Contains the public key for authentication.
  1572. These files are not
  1573. sensitive and can (but need not) be readable by anyone.
  1574. .Pp
  1575. .It Pa ~/.ssh/known_hosts
  1576. Contains a list of host keys for all hosts the user has logged into
  1577. that are not already in the systemwide list of known host keys.
  1578. See
  1579. .Xr sshd 8
  1580. for further details of the format of this file.
  1581. .Pp
  1582. .It Pa ~/.ssh/rc
  1583. Commands in this file are executed by
  1584. .Nm
  1585. when the user logs in, just before the user's shell (or command) is
  1586. started.
  1587. See the
  1588. .Xr sshd 8
  1589. manual page for more information.
  1590. .Pp
  1591. .It Pa /etc/hosts.equiv
  1592. This file is for host-based authentication (see above).
  1593. It should only be writable by root.
  1594. .Pp
  1595. .It Pa /etc/shosts.equiv
  1596. This file is used in exactly the same way as
  1597. .Pa hosts.equiv ,
  1598. but allows host-based authentication without permitting login with
  1599. rlogin/rsh.
  1600. .Pp
  1601. .It Pa /etc/ssh/ssh_config
  1602. Systemwide configuration file.
  1603. The file format and configuration options are described in
  1604. .Xr ssh_config 5 .
  1605. .Pp
  1606. .It Pa /etc/ssh/ssh_host_key
  1607. .It Pa /etc/ssh/ssh_host_dsa_key
  1608. .It Pa /etc/ssh/ssh_host_ecdsa_key
  1609. .It Pa /etc/ssh/ssh_host_ed25519_key
  1610. .It Pa /etc/ssh/ssh_host_rsa_key
  1611. These files contain the private parts of the host keys
  1612. and are used for host-based authentication.
  1613. .Pp
  1614. .It Pa /etc/ssh/ssh_known_hosts
  1615. Systemwide list of known host keys.
  1616. This file should be prepared by the
  1617. system administrator to contain the public host keys of all machines in the
  1618. organization.
  1619. It should be world-readable.
  1620. See
  1621. .Xr sshd 8
  1622. for further details of the format of this file.
  1623. .Pp
  1624. .It Pa /etc/ssh/sshrc
  1625. Commands in this file are executed by
  1626. .Nm
  1627. when the user logs in, just before the user's shell (or command) is started.
  1628. See the
  1629. .Xr sshd 8
  1630. manual page for more information.
  1631. .El
  1632. .Sh EXIT STATUS
  1633. .Nm
  1634. exits with the exit status of the remote command or with 255
  1635. if an error occurred.
  1636. .Sh IPV6
  1637. IPv6 address can be used everywhere where IPv4 address. In all entries must be the IPv6 address enclosed in square brackets. Note: The square brackets are metacharacters for the shell and must be escaped in shell.
  1638. .Sh SEE ALSO
  1639. .Xr scp 1 ,
  1640. .Xr sftp 1 ,
  1641. .Xr ssh-add 1 ,
  1642. .Xr ssh-agent 1 ,
  1643. .Xr ssh-keygen 1 ,
  1644. .Xr ssh-keyscan 1 ,
  1645. .Xr tun 4 ,
  1646. .Xr ssh_config 5 ,
  1647. .Xr ssh-keysign 8 ,
  1648. .Xr sshd 8
  1649. .Sh STANDARDS
  1650. .Rs
  1651. .%A S. Lehtinen
  1652. .%A C. Lonvick
  1653. .%D January 2006
  1654. .%R RFC 4250
  1655. .%T The Secure Shell (SSH) Protocol Assigned Numbers
  1656. .Re
  1657. .Pp
  1658. .Rs
  1659. .%A T. Ylonen
  1660. .%A C. Lonvick
  1661. .%D January 2006
  1662. .%R RFC 4251
  1663. .%T The Secure Shell (SSH) Protocol Architecture
  1664. .Re
  1665. .Pp
  1666. .Rs
  1667. .%A T. Ylonen
  1668. .%A C. Lonvick
  1669. .%D January 2006
  1670. .%R RFC 4252
  1671. .%T The Secure Shell (SSH) Authentication Protocol
  1672. .Re
  1673. .Pp
  1674. .Rs
  1675. .%A T. Ylonen
  1676. .%A C. Lonvick
  1677. .%D January 2006
  1678. .%R RFC 4253
  1679. .%T The Secure Shell (SSH) Transport Layer Protocol
  1680. .Re
  1681. .Pp
  1682. .Rs
  1683. .%A T. Ylonen
  1684. .%A C. Lonvick
  1685. .%D January 2006
  1686. .%R RFC 4254
  1687. .%T The Secure Shell (SSH) Connection Protocol
  1688. .Re
  1689. .Pp
  1690. .Rs
  1691. .%A J. Schlyter
  1692. .%A W. Griffin
  1693. .%D January 2006
  1694. .%R RFC 4255
  1695. .%T Using DNS to Securely Publish Secure Shell (SSH) Key Fingerprints
  1696. .Re
  1697. .Pp
  1698. .Rs
  1699. .%A F. Cusack
  1700. .%A M. Forssen
  1701. .%D January 2006
  1702. .%R RFC 4256
  1703. .%T Generic Message Exchange Authentication for the Secure Shell Protocol (SSH)
  1704. .Re
  1705. .Pp
  1706. .Rs
  1707. .%A J. Galbraith
  1708. .%A P. Remaker
  1709. .%D January 2006
  1710. .%R RFC 4335
  1711. .%T The Secure Shell (SSH) Session Channel Break Extension
  1712. .Re
  1713. .Pp
  1714. .Rs
  1715. .%A M. Bellare
  1716. .%A T. Kohno
  1717. .%A C. Namprempre
  1718. .%D January 2006
  1719. .%R RFC 4344
  1720. .%T The Secure Shell (SSH) Transport Layer Encryption Modes
  1721. .Re
  1722. .Pp
  1723. .Rs
  1724. .%A B. Harris
  1725. .%D January 2006
  1726. .%R RFC 4345
  1727. .%T Improved Arcfour Modes for the Secure Shell (SSH) Transport Layer Protocol
  1728. .Re
  1729. .Pp
  1730. .Rs
  1731. .%A M. Friedl
  1732. .%A N. Provos
  1733. .%A W. Simpson
  1734. .%D March 2006
  1735. .%R RFC 4419
  1736. .%T Diffie-Hellman Group Exchange for the Secure Shell (SSH) Transport Layer Protocol
  1737. .Re
  1738. .Pp
  1739. .Rs
  1740. .%A J. Galbraith
  1741. .%A R. Thayer
  1742. .%D November 2006
  1743. .%R RFC 4716
  1744. .%T The Secure Shell (SSH) Public Key File Format
  1745. .Re
  1746. .Pp
  1747. .Rs
  1748. .%A D. Stebila
  1749. .%A J. Green
  1750. .%D December 2009
  1751. .%R RFC 5656
  1752. .%T Elliptic Curve Algorithm Integration in the Secure Shell Transport Layer
  1753. .Re
  1754. .Pp
  1755. .Rs
  1756. .%A A. Perrig
  1757. .%A D. Song
  1758. .%D 1999
  1759. .%O International Workshop on Cryptographic Techniques and E-Commerce (CrypTEC '99)
  1760. .%T Hash Visualization: a New Technique to improve Real-World Security
  1761. .Re
  1762. .Sh AUTHORS
  1763. OpenSSH is a derivative of the original and free
  1764. ssh 1.2.12 release by Tatu Ylonen.
  1765. Aaron Campbell, Bob Beck, Markus Friedl, Niels Provos,
  1766. Theo de Raadt and Dug Song
  1767. removed many bugs, re-added newer features and
  1768. created OpenSSH.
  1769. Markus Friedl contributed the support for SSH
  1770. protocol versions 1.5 and 2.0.