1
0

ssh 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536
  1. .TH SSH 4
  2. .SH NAME
  3. ssh, netssh \- serve SSH v2 over TCP
  4. .SH SYNOPSIS
  5. .B netssh
  6. [
  7. .B -9dkv
  8. ] [
  9. .B -m
  10. .I mntpt
  11. ] [
  12. .B -s
  13. .I srvpt
  14. ]
  15. .PP
  16. .2C
  17. .B "cd /net/ssh"
  18. .B ./clone
  19. .B ./ctl
  20. .B ./keys
  21. .BI ./ n
  22. .BI ./ n /clone
  23. .BI ./ n /ctl
  24. .BI ./ n /data
  25. .BI ./ n /listen
  26. .BI ./ n /local
  27. .BI ./ n /remote
  28. .BI ./ n /status
  29. .BI ./ n /tcp
  30. \&...
  31. .BI ./ n / ch
  32. .BI ./ n / ch /ctl
  33. .BI ./ n / ch /data
  34. .BI ./ n / ch /listen
  35. .BI ./ n / ch /request
  36. .BI ./ n / ch /status
  37. \&...
  38. .1C
  39. .fi
  40. .SH DESCRIPTION
  41. The
  42. .I netssh
  43. file server implements SSH v2 over TCP.
  44. All of the encryption, authentication, and SSH protocol are handled
  45. by a server managing SSH tunnels
  46. that appears as a protocol directory,
  47. .BR /net/ssh ,
  48. similar to those of
  49. .IR ip (3)
  50. but with an extra level of hierarchy for SSH channels within connections.
  51. Options are:
  52. .TF -m
  53. .TP
  54. .B -d
  55. Increase the amount of debugging output.
  56. .TP
  57. .B -k
  58. Use
  59. .IR keyfs (4)
  60. for password validation.
  61. .TP
  62. .B -m
  63. Mount point for the SSH protocol directory; defaults to
  64. .BR /net .
  65. .TP
  66. .B -s
  67. Name to post in
  68. .BR /srv .
  69. If
  70. .B -s
  71. is not given, no file is posted to
  72. .BR /srv .
  73. .TP
  74. .B -v
  75. Do not verify the remote system's host key (which is somewhat pedantic anyway).
  76. This lets us talk to SSH v1 systems.
  77. The presence of
  78. .B /env/nosshkeyverify
  79. is equivalent to specifying this option.
  80. .PD
  81. .LP
  82. .B /net/ssh
  83. contains a set of numbered directories, each of which
  84. is an SSH connection that is currently active or has been used in the past,
  85. per
  86. .IR ip (3).
  87. Opening
  88. .B clone
  89. reserves an SSH connection, reading from
  90. it returns the connection number reserved, and writing to it writes to the
  91. .B ctl
  92. file in the numbered connection directory.
  93. Reading the
  94. .B ctl
  95. file returns the most active state of any connection.
  96. .B /net/ssh/ctl
  97. currently implements no commands.
  98. Finally, the
  99. .B keys
  100. file is used by
  101. .IR ssh2 (1)
  102. to relay information about keys and passwords between a user and the SSH server.
  103. .LP
  104. Each of the numbered connection directories contains
  105. a set of numbered directories, one for each channel used on
  106. that connection (see
  107. .ft B
  108. Channel Directories
  109. .ft
  110. below).
  111. Similar to the top-level
  112. .B clone
  113. file, opening a connection's
  114. .B clone
  115. file reserves a channel and gives access to its
  116. .B ctl
  117. file.
  118. Reading from the
  119. .B ctl
  120. file returns the connection number (also the name of that directory).
  121. Commands may be written to a connection's
  122. .B ctl
  123. file:
  124. .TF connect
  125. .TP
  126. .B connect
  127. Dial the remote system and perform the initial
  128. handshake to exchange versions, lists of supported algorithms,
  129. and to establish the encryption keys to use.
  130. .TP
  131. .B ssh-userauth
  132. Attempt to authenticate a user with the remote system, with either
  133. public key authentication or a password.
  134. .TP
  135. .B ssh-connection
  136. Currently unsupported.
  137. .TP
  138. .B hangup
  139. Shut down a connection and all of its channels.
  140. .TP
  141. .B announce
  142. .B /net/ssh
  143. will accept connection requests from remote systems.
  144. .TP
  145. .B accept
  146. Do the initial connection handshake with the calling system.
  147. .TP
  148. .B reject
  149. Send back a connection rejection message to the caller
  150. and shut down the connection.
  151. .PD
  152. .LP
  153. Because data is always carried over a channel, the connection data file
  154. is not used for usual data.
  155. However, reads from the connection data file do return the capability
  156. needed for
  157. .I sshsession
  158. to change identity to the user logging in.
  159. As with other protocol directories, opens on
  160. .B listen
  161. block until a remote system establishes a connection, at which point,
  162. a server should write either an
  163. .B accept
  164. or
  165. .B reject
  166. message to the
  167. .B ctl
  168. file.
  169. The
  170. .B local
  171. and
  172. .B remote
  173. files give the IP addresses and port numbers of the local and remote
  174. systems.
  175. The connection
  176. .B status
  177. file gives the status of the most-recently established channel.
  178. .
  179. .SS "Channel Directories"
  180. In each channel directory,
  181. .BI /net/ssh/ conn / chan\fR,
  182. reads from channel
  183. .B ctl
  184. files return the channel number.
  185. Commands that may be written to a channel
  186. .B ctl
  187. file include:
  188. .TF connect
  189. .TP
  190. .B connect
  191. Create a new channel over this connection.
  192. SSHv2 defines
  193. .BR session ,
  194. .BR x11 ,
  195. .BR forwarded-tcpip ,
  196. and
  197. .B direct-tcpip
  198. channels.
  199. The
  200. .B connect
  201. command defaults to a
  202. .B session
  203. channel if no argument is given.
  204. (This implementation correctly handles only session channel requests.)
  205. .TP
  206. .B global
  207. Reserved for future development.
  208. In particular, this is necessary to support TCP/IP forwarding.
  209. .TP
  210. .B hangup
  211. Shut down a channel.
  212. If this is the last open channel on this connection, then shut down
  213. the connection too.
  214. .TP
  215. .B announce
  216. Announce willingness to accept new channel requests from the calling system.
  217. .PD
  218. .LP
  219. The channel
  220. .B data
  221. file is the file over which all application data is carried.
  222. Opens of the channel
  223. .B listen
  224. file block until a channel is opened by the remote end.
  225. Unlike the connection
  226. .B listen
  227. file, the listening program should not write an
  228. .B accept
  229. or
  230. .B reject
  231. message to the
  232. .B ctl
  233. file.
  234. .PP
  235. SSHv2 defines a number of out-of-band channel requests,
  236. sent and received through the
  237. .B request
  238. file.
  239. Among these are
  240. .BR env ,
  241. .BR exec ,
  242. .BR exit-signal ,
  243. .BR exit-status ,
  244. .BR pty-req ,
  245. .BR shell ,
  246. .BR signal ,
  247. .BR subsystem ,
  248. .BR window-change ,
  249. .BR x11-req ,
  250. and
  251. .BR xon-xoff .
  252. .I Sshsession
  253. only fully handles the
  254. .B shell
  255. and
  256. .B exec
  257. requests.
  258. Others are blithely acknowledged, rejected or ignored,
  259. depending on whether they are expected to be available by
  260. the remote system.
  261. .PP
  262. The channel
  263. .B status
  264. file contains one of:
  265. .BR Empty ,
  266. .BR Allocated ,
  267. .BR Initting ,
  268. .BR Listening ,
  269. .BR Opening ,
  270. .BR Negotiating ,
  271. .BR Authing ,
  272. .BR Established ,
  273. .BR Eof ,
  274. .BR Closing ,
  275. or
  276. .BR Closed .
  277. .
  278. .SS "Cryptographic Algorithms"
  279. During the initial connection exchange, both parties send lists of
  280. supported algorithms.
  281. The first list is for key exchange;
  282. we support
  283. .B diffie-hellman-group1-sha1
  284. and
  285. .BR diffie-hellman-group14-sha1 .
  286. The second list is the set for which corresponding host keys exist;
  287. we support
  288. .B ssh-rsa
  289. and
  290. .BR ssh-dss .
  291. The next lists are encryption algorithms, which may be negotiated
  292. independently for the server-to-client and client-to-server directions;
  293. we support
  294. .BR aes128-cbc ,
  295. .BR aes192-cbc ,
  296. .BR aes256-cbc ,
  297. .BR 3des-cbc ,
  298. and
  299. .B arcfour
  300. with preference given in that order.
  301. The final list is message authentication code algorithms;
  302. we only support
  303. .BR hmac-sha1 .
  304. .
  305. .SS "Keys and Management"
  306. Various keys are used by the SSH server.
  307. Most of them are expected to be stored in the instance of
  308. .IR factotum (4)
  309. running in the namespace of that server instance.
  310. Sometimes there are alternative locations.
  311. .LP
  312. The first key needed is the host key for server operation.
  313. In the case of the keys being stored in
  314. .IR factotum (4),
  315. these keys will be the first ones listed with
  316. .B proto=rsa
  317. and
  318. .BR proto=dss .
  319. Alternatively, these keys can be specified in the environment variables
  320. .B rsakey
  321. and
  322. .B dsskey
  323. or in files of the same names in the directory where
  324. .I netssh
  325. is started.
  326. .LP
  327. The next set of keys are the public host keys used by clients to
  328. verify the identities of servers.
  329. As with the original Plan 9 SSH implementation,
  330. there is a system-wide list of these in
  331. .B /sys/lib/ssh/keyring
  332. and each user may have a list in
  333. .BR $home/lib/keyring .
  334. If a public key for a remote server is listed and matches the one
  335. offered by the server, the connection proceeds.
  336. If a public key for a remote server is listed but does not match
  337. the one offered by the server, or
  338. if no public key is listed for a remote server,
  339. .I ssh
  340. (see
  341. .IR ssh2 (1))
  342. presents the key to the user and asks whether to reject the
  343. key, accept the key only for that session, or accept the key permanently.
  344. The last option causes the key to be written to the user's keyring.
  345. In the case of a mismatching key, the accept option can
  346. either be to add to or replace the old key.
  347. .LP
  348. An SSH daemon,
  349. such as
  350. .I sshsession
  351. in
  352. .IR ssh2 (1),
  353. must also have a list of public keys
  354. for public key authentication.
  355. Again, these keys must be stored in the
  356. .I factotum
  357. instance running in the name space of the daemon's SSH server.
  358. Each such key must have the attributes
  359. .BR role=verify,
  360. .BR proto=rsa ,
  361. and either
  362. .B user=
  363. or
  364. .BR sys= .
  365. .LP
  366. The next key is a user's private key to be used for public key authentication.
  367. We only support RSA keys for this, and the key must be in the
  368. .I factotum
  369. instance running in the namespace of the
  370. .IR ssh (4)
  371. instance.
  372. Creating a key and putting it in
  373. .I factotum
  374. can be done by:
  375. .IP
  376. .EX
  377. auth/rsagen >key; read -m key >/mnt/factotum/ctl
  378. .EE
  379. .LP
  380. The key file will normally be loaded when
  381. .I factotum
  382. is started, either by way of
  383. .IR secstore (1)
  384. or directly in the user's
  385. .BR lib/profile .
  386. See
  387. .IR ssh2 (1)
  388. for
  389. .IR rsa2ssh2 .
  390. .LP
  391. The command
  392. .IP
  393. .EX
  394. auth/pemdecode 'RSA PRIVATE KEY' id_rsa | auth/asn12rsa >key
  395. .EE
  396. .LP
  397. will translate a private key used with OpenSSH to one suitable
  398. for loading into
  399. .IR factotum .
  400. .LP
  401. To disambiguate when a user has more than one private key stored in
  402. .IR factotum ,
  403. the following selection criteria are applied:
  404. .TF "M."
  405. .PD 0.2v
  406. .TP 3
  407. 1.
  408. The selected key must have both
  409. .B proto=rsa
  410. and
  411. .B !dk=
  412. attributes present.
  413. .TP
  414. 2.
  415. Among those keys, the attributes
  416. .BR user= ,
  417. .BR sys= ,
  418. and any attribute/value pair specified in a
  419. .B -z
  420. option to
  421. .I ssh
  422. are examined.
  423. The value of the
  424. .B user
  425. attribute is expected to be the user name being authenticated on the remote
  426. system, and the value of the
  427. .B sys
  428. attribute is expected to be the remote system as specified in the
  429. .I ssh
  430. invocation.
  431. .TP
  432. 3.
  433. The key with the greatest number of matches (most specific match) is selected.
  434. Among keys with equal number of matches, the first is chosen.
  435. .PD
  436. .LP
  437. For password-based user authentication,
  438. .I netssh
  439. can run in one of two modes.
  440. If given
  441. .BR -k ,
  442. it will validate passwords against those stored in
  443. .B /mnt/keys
  444. provided by
  445. .IR keyfs (4).
  446. If run without
  447. .BR -k ,
  448. it will validate passwords with an authentication server using
  449. .I auth_userpasswd
  450. in
  451. .IR auth (2).
  452. .SH FILES
  453. .TF /sys/lib/ssh/keyring
  454. .TP
  455. .B /sys/lib/ssh/keyring
  456. System-wide known host public keys.
  457. .TP
  458. .B $home/lib/keyring
  459. Per-user known host public keys.
  460. .TP
  461. .B /env/nosshkeyverify
  462. .SH SOURCE
  463. .B /sys/src/cmd/ssh2
  464. .SH "SEE ALSO"
  465. .IR ssh2 (1),
  466. .IR ip (3),
  467. .IR factotum (4),
  468. .IR keyfs (4),
  469. .IR authsrv (6),
  470. .IR dsa (8),
  471. .IR rsa (8)
  472. .br
  473. RFCs 4250, 4251, 4252, 4253, 4254, and 4419
  474. .SH BUGS
  475. .I Netssh
  476. shouldn't have to run as the host owner and using
  477. .IR factotum (4)
  478. correctly would permit this.
  479. .PP
  480. .I Netssh
  481. should be simplified by removing the top (connection) level of the
  482. .B /net/ssh
  483. hierarchy and multiplexing a single network connection
  484. after the initial negotiation.
  485. This would fit better with
  486. .IR dial (2),
  487. permit transports other than TCP,
  488. and allow co-existence of v1 and v2 implementations on a single TCP port.
  489. Better still,
  490. use only a single channel (since we don't use X11)
  491. and eliminate the top 2 levels.
  492. .PP
  493. .I Netssh
  494. authentication via
  495. .I keyfs
  496. and public keys uses
  497. .LR #¤/caphash ,
  498. which isn't normally present after
  499. .I cpurc
  500. runs, so
  501. .I netssh
  502. needs to be converted to use
  503. .IR factotum .
  504. .PP
  505. .B netssh
  506. .B -k
  507. assumes that
  508. .I keyfs
  509. is mounted,
  510. which is typically only true of authentication servers.
  511. .PP
  512. The
  513. .B keys
  514. file protocol should be documented.
  515. .PP
  516. Only capable of using TCP for underlying connections.
  517. .PP
  518. Can't coexist with SSH v1 on the same port.
  519. .PP
  520. Several aspects of key management still need some work.
  521. .PP
  522. TCP/IP forwarding and some potentially useful channel requests have not
  523. been implemented.
  524. .PP
  525. .B Zlib
  526. compression is not supported and probably not needed.
  527. .PP
  528. The SSH v2 protocol is a classic second system:
  529. over-engineered,
  530. overly complicated,
  531. misdesigned
  532. and
  533. jammed full of pointless goodies.
  534. .PP
  535. Host key verification is broken, so it's disabled temporarily
  536. until it's fixed.