using.but 42 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003
  1. \C{using} Using PuTTY
  2. This chapter provides a general introduction to some more advanced
  3. features of PuTTY. For extreme detail and reference purposes,
  4. \k{config} is likely to contain more information.
  5. \H{using-session} During your session
  6. A lot of PuTTY's complexity and features are in the configuration
  7. panel. Once you have worked your way through that and started
  8. a session, things should be reasonably simple after that.
  9. Nevertheless, there are a few more useful features available.
  10. \S{using-selection} Copying and pasting text
  11. \I{copy and paste}Often in a PuTTY session you will find text on
  12. your terminal screen which you want to type in again. Like most
  13. other terminal emulators, PuTTY allows you to copy and paste the
  14. text rather than having to type it again. Also, copy and paste uses
  15. the \I{Windows clipboard}Windows \i{clipboard}, so that you can
  16. paste (for example) URLs into a web browser, or paste from a word
  17. processor or spreadsheet into your terminal session.
  18. PuTTY's copy and paste works entirely with the \i{mouse}. In order
  19. to copy text to the clipboard, you just click the \i{left mouse
  20. button} in the \i{terminal window}, and drag to \I{selecting text}select
  21. text. When you let go of the button, the text is \e{automatically}
  22. copied to the clipboard. You do not need to press Ctrl-C or
  23. Ctrl-Ins; in fact, if you do press Ctrl-C, PuTTY will send a Ctrl-C
  24. character down your session to the server where it will probably
  25. cause a process to be interrupted.
  26. Pasting is done using the right button (or the middle mouse button,
  27. if you have a \i{three-button mouse} and have set it up; see
  28. \k{config-mouse}). (Pressing \i{Shift-Ins}, or selecting \q{Paste}
  29. from the \I{right mouse button, with Ctrl}Ctrl+right-click
  30. \i{context menu}, have the same effect.) When
  31. you click the \i{right mouse button}, PuTTY will read whatever is in
  32. the Windows clipboard and paste it into your session, \e{exactly} as
  33. if it had been typed at the keyboard. (Therefore, be careful of
  34. pasting formatted text into an editor that does automatic indenting;
  35. you may find that the spaces pasted from the clipboard plus the
  36. spaces added by the editor add up to too many spaces and ruin the
  37. formatting. There is nothing PuTTY can do about this.)
  38. If you \i{double-click} the left mouse button, PuTTY will
  39. \I{selecting words}select a whole word. If you double-click, hold
  40. down the second click, and drag the mouse, PuTTY will select a
  41. sequence of whole words. (You can adjust precisely what PuTTY
  42. considers to be part of a word; see \k{config-charclasses}.)
  43. If you \e{triple}-click, or \i{triple-click} and drag, then
  44. PuTTY will \I{selecting lines}select a whole line or sequence of lines.
  45. If you want to select a \I{rectangular selection}rectangular region
  46. instead of selecting to the end of each line, you can do this by
  47. holding down Alt when you make your selection. You can also
  48. configure rectangular selection to be the default, and then holding
  49. down Alt gives the normal behaviour instead: see
  50. \k{config-rectselect} for details.
  51. (In some Unix environments, Alt+drag is intercepted by the window
  52. manager. Shift+Alt+drag should work for rectangular selection as
  53. well, so you could try that instead.)
  54. If you have a \i{middle mouse button}, then you can use it to
  55. \I{adjusting a selection}adjust an existing selection if you
  56. selected something slightly wrong. (If you have configured the
  57. middle mouse button to paste, then the right mouse button does this
  58. instead.) Click the button on the screen, and you can pick up the
  59. nearest end of the selection and drag it to somewhere else.
  60. It's possible for the server to ask to \I{mouse reporting}handle mouse
  61. clicks in the PuTTY window itself. If this happens, the \i{mouse pointer}
  62. will turn into an arrow, and using the mouse to copy and paste will only
  63. work if you hold down Shift. See \k{config-features-mouse} and
  64. \k{config-mouseshift} for details of this feature and how to configure
  65. it.
  66. \S{using-scrollback} \I{scrollback}Scrolling the screen back
  67. PuTTY keeps track of text that has scrolled up off the top of the
  68. terminal. So if something appears on the screen that you want to
  69. read, but it scrolls too fast and it's gone by the time you try to
  70. look for it, you can use the \i{scrollbar} on the right side of the
  71. window to look back up the session \i{history} and find it again.
  72. As well as using the scrollbar, you can also page the scrollback up
  73. and down by pressing \i{Shift-PgUp} and \i{Shift-PgDn}. You can
  74. scroll a line at a time using \i{Ctrl-PgUp} and \i{Ctrl-PgDn}. These
  75. are still available if you configure the scrollbar to be invisible.
  76. By default the last 2000 lines scrolled off the top are
  77. preserved for you to look at. You can increase (or decrease) this
  78. value using the configuration box; see \k{config-scrollback}.
  79. \S{using-sysmenu} The \ii{System menu}
  80. If you click the left mouse button on the icon in the top left
  81. corner of PuTTY's terminal window, or click the right mouse button
  82. on the title bar, you will see the standard Windows system menu
  83. containing items like Minimise, Move, Size and Close.
  84. PuTTY's system menu contains extra program features in addition to
  85. the Windows standard options. These extra menu commands are
  86. described below.
  87. (These options are also available in a \i{context menu} brought up
  88. by holding Ctrl and clicking with the right mouse button anywhere
  89. in the \i{PuTTY window}.)
  90. \S2{using-eventlog} The PuTTY \i{Event Log}
  91. If you choose \q{Event Log} from the system menu, a small window
  92. will pop up in which PuTTY logs significant events during the
  93. connection. Most of the events in the log will probably take place
  94. during session startup, but a few can occur at any point in the
  95. session, and one or two occur right at the end.
  96. You can use the mouse to select one or more lines of the Event Log,
  97. and hit the Copy button to copy them to the \i{clipboard}. If you
  98. are reporting a bug, it's often useful to paste the contents of the
  99. Event Log into your bug report.
  100. (The Event Log is not the same as the facility to create a log file
  101. of your session; that's described in \k{using-logging}.)
  102. \S2{using-specials} \ii{Special commands}
  103. Depending on the protocol used for the current session, there may be
  104. a submenu of \q{special commands}. These are protocol-specific
  105. tokens, such as a \q{break} signal, that can be sent down a
  106. connection in addition to normal data. Their precise effect is usually
  107. up to the server. Currently only Telnet, SSH, and serial connections
  108. have special commands.
  109. The \q{break} signal can also be invoked from the keyboard with
  110. \i{Ctrl-Break}.
  111. The following \I{Telnet special commands}special commands are
  112. available in Telnet:
  113. \b \I{Are You There, Telnet special command}Are You There
  114. \b \I{Break, Telnet special command}Break
  115. \b \I{Synch, Telnet special command}Synch
  116. \b \I{Erase Character, Telnet special command}Erase Character
  117. \lcont{
  118. PuTTY can also be configured to send this when the Backspace key is
  119. pressed; see \k{config-telnetkey}.
  120. }
  121. \b \I{Erase Line, Telnet special command}Erase Line
  122. \b \I{Go Ahead, Telnet special command}Go Ahead
  123. \b \I{No Operation, Telnet special command}No Operation
  124. \lcont{
  125. Should have no effect.
  126. }
  127. \b \I{Abort Process, Telnet special command}Abort Process
  128. \b \I{Abort Output, Telnet special command}Abort Output
  129. \b \I{Interrupt Process, Telnet special command}Interrupt Process
  130. \lcont{
  131. PuTTY can also be configured to send this when Ctrl-C is typed; see
  132. \k{config-telnetkey}.
  133. }
  134. \b \I{Suspend Process, Telnet special command}Suspend Process
  135. \lcont{
  136. PuTTY can also be configured to send this when Ctrl-Z is typed; see
  137. \k{config-telnetkey}.
  138. }
  139. \b \I{End Of Record, Telnet special command}End Of Record
  140. \b \I{End Of File, Telnet special command}End Of File
  141. In an SSH connection, the following \I{SSH special commands}special
  142. commands are available:
  143. \b \I{IGNORE message, SSH special command}\I{No-op, in SSH}\ii{IGNORE message}
  144. \lcont{
  145. Should have no effect.
  146. }
  147. \b \I{Repeat key exchange, SSH special command}Repeat key exchange
  148. \lcont{
  149. Only available in SSH-2. Forces a \i{repeat key exchange} immediately (and
  150. resets associated timers and counters). For more information about
  151. repeat key exchanges, see \k{config-ssh-kex-rekey}.
  152. }
  153. \b \I{host key cache}Cache new host key type
  154. \lcont{
  155. Only available in SSH-2. This submenu appears only if the server has
  156. host keys of a type that PuTTY doesn't already have cached, and so
  157. won't consider. Selecting a key here will allow PuTTY to use that key
  158. now and in future: PuTTY will do a fresh key-exchange with the selected
  159. key, and immediately add that key to its permanent cache (relying on
  160. the host key used at the start of the connection to cross-certify the
  161. new key). That key will be used for the rest of the current session;
  162. it may not actually be used for future sessions, depending on your
  163. preferences (see \k{config-ssh-hostkey-order}).
  164. Normally, PuTTY will carry on using a host key it already knows, even
  165. if the server offers key formats that PuTTY would otherwise prefer,
  166. to avoid host key prompts. As a result, if you've been using a server
  167. for some years, you may still be using an older key than a new user
  168. would use, due to server upgrades in the meantime. The SSH protocol
  169. unfortunately does not have organised facilities for host key migration
  170. and rollover, but this allows you to \I{host keys, upgrading}manually
  171. upgrade.
  172. }
  173. \b \I{Break, SSH special command}Break
  174. \lcont{
  175. Only available in SSH-2, and only during a session. Optional
  176. extension; may not be supported by server. PuTTY requests the server's
  177. default break length.
  178. }
  179. \b \I{Signal, SSH special command}Signals (SIGINT, SIGTERM etc)
  180. \lcont{
  181. Only available in SSH-2, and only during a session. Sends various
  182. POSIX signals. Not honoured by all servers.
  183. }
  184. With a serial connection, the only available special command is
  185. \I{Break, serial special command}\q{Break}.
  186. \S2{using-newsession} Starting new sessions
  187. PuTTY's system menu provides some shortcut ways to start new
  188. sessions:
  189. \b Selecting \i{\q{New Session}} will start a completely new
  190. instance of PuTTY, and bring up the configuration box as normal.
  191. \b Selecting \i{\q{Duplicate Session}} will start a session in a
  192. new window with precisely the same options as your current one -
  193. connecting to the same host using the same protocol, with all the
  194. same terminal settings and everything.
  195. \b In an inactive window, selecting \i{\q{Restart Session}} will
  196. do the same as \q{Duplicate Session}, but in the current window.
  197. \b The \i{\q{Saved Sessions} submenu} gives you quick access to any
  198. sets of stored session details you have previously saved. See
  199. \k{config-saving} for details of how to create saved sessions.
  200. \S2{using-changesettings} \I{settings, changing}Changing your
  201. session settings
  202. If you select \i{\q{Change Settings}} from the system menu, PuTTY will
  203. display a cut-down version of its initial configuration box. This
  204. allows you to adjust most properties of your current session. You
  205. can change the terminal size, the font, the actions of various
  206. keypresses, the colours, and so on.
  207. Some of the options that are available in the main configuration box
  208. are not shown in the cut-down Change Settings box. These are usually
  209. options which don't make sense to change in the middle of a session
  210. (for example, you can't switch from SSH to Telnet in mid-session).
  211. You can save the current settings to a saved session for future use
  212. from this dialog box. See \k{config-saving} for more on saved
  213. sessions.
  214. \S2{using-copyall} \i{Copy All to Clipboard}
  215. This system menu option provides a convenient way to copy the whole
  216. contents of the terminal screen (up to the last nonempty line) and
  217. scrollback to the \i{clipboard} in one go.
  218. \S2{reset-terminal} \I{scrollback, clearing}Clearing and
  219. \I{terminal, resetting}resetting the terminal
  220. The \i{\q{Clear Scrollback}} option on the system menu tells PuTTY
  221. to discard all the lines of text that have been kept after they
  222. scrolled off the top of the screen. This might be useful, for
  223. example, if you displayed sensitive information and wanted to make
  224. sure nobody could look over your shoulder and see it. (Note that
  225. this only prevents a casual user from using the scrollbar to view
  226. the information; the text is not guaranteed not to still be in
  227. PuTTY's memory.)
  228. The \i{\q{Reset Terminal}} option causes a full reset of the
  229. \i{terminal emulation}. A VT-series terminal is a complex piece of
  230. software and can easily get into a state where all the text printed
  231. becomes unreadable. (This can happen, for example, if you
  232. accidentally output a binary file to your terminal.) If this
  233. happens, selecting Reset Terminal should sort it out.
  234. \S2{using-fullscreen} \ii{Full screen} mode
  235. If you find the title bar on a maximised window to be ugly or
  236. distracting, you can select Full Screen mode to maximise PuTTY
  237. \q{even more}. When you select this, PuTTY will expand to fill the
  238. whole screen and its borders, title bar and scrollbar will
  239. disappear. (You can configure the scrollbar not to disappear in
  240. full-screen mode if you want to keep it; see \k{config-scrollback}.)
  241. When you are in full-screen mode, you can still access the \i{system
  242. menu} if you click the left mouse button in the \e{extreme} top left
  243. corner of the screen.
  244. \H{using-logging} Creating a \i{log file} of your \I{session
  245. log}session
  246. For some purposes you may find you want to log everything that
  247. appears on your screen. You can do this using the \q{Logging}
  248. panel in the configuration box.
  249. To begin a session log, select \q{Change Settings} from the system
  250. menu and go to the Logging panel. Enter a log file name, and select
  251. a logging mode. (You can log all session output including the
  252. terminal \i{control sequence}s, or you can just log the printable text.
  253. It depends what you want the log for.) Click \q{Apply} and your log
  254. will be started. Later on, you can go back to the Logging panel and
  255. select \q{Logging turned off completely} to stop logging; then PuTTY
  256. will close the log file and you can safely read it.
  257. See \k{config-logging} for more details and options.
  258. \H{using-translation} Altering your \i{character set} configuration
  259. If you find that special characters (\i{accented characters}, for
  260. example, or \i{line-drawing characters}) are not being displayed
  261. correctly in your PuTTY session, it may be that PuTTY is interpreting
  262. the characters sent by the server according to the wrong \e{character
  263. set}. There are a lot of different character sets available, and no
  264. good way for PuTTY to know which to use, so it's entirely possible
  265. for this to happen.
  266. If you click \q{Change Settings} and look at the \q{Translation}
  267. panel, you should see a large number of character sets which you can
  268. select, and other related options. Now all you need is to find out
  269. which of them you want! (See \k{config-translation} for more
  270. information.)
  271. \H{using-x-forwarding} Using \i{X11 forwarding} in SSH
  272. The SSH protocol has the ability to securely forward X Window System
  273. \i{graphical applications} over your encrypted SSH connection, so that
  274. you can run an application on the SSH server machine and have it put
  275. its windows up on your local machine without sending any X network
  276. traffic in the clear.
  277. In order to use this feature, you will need an X display server for
  278. your Windows machine, such as Cygwin/X, X-Win32, or Exceed. This will probably
  279. install itself as display number 0 on your local machine; if it
  280. doesn't, the manual for the \i{X server} should tell you what it
  281. does do.
  282. You should then tick the \q{Enable X11 forwarding} box in the
  283. X11 panel (see \k{config-ssh-x11}) before starting your SSH
  284. session. The \i{\q{X display location}} box is blank by default, which
  285. means that PuTTY will try to use a sensible default such as \c{:0},
  286. which is the usual display location where your X server will be
  287. installed. If that needs changing, then change it.
  288. Now you should be able to log in to the SSH server as normal. To
  289. check that X forwarding has been successfully negotiated during
  290. connection startup, you can check the PuTTY Event Log (see
  291. \k{using-eventlog}). It should say something like this:
  292. \c 2001-12-05 17:22:01 Requesting X11 forwarding
  293. \c 2001-12-05 17:22:02 X11 forwarding enabled
  294. If the remote system is Unix or Unix-like, you should also be able
  295. to see that the \i{\c{DISPLAY} environment variable} has been set to
  296. point at display 10 or above on the SSH server machine itself:
  297. \c fred@unixbox:~$ echo $DISPLAY
  298. \c unixbox:10.0
  299. If this works, you should then be able to run X applications in the
  300. remote session and have them display their windows on your PC.
  301. For more options relating to X11 forwarding, see \k{config-ssh-x11}.
  302. \H{using-port-forwarding} Using \i{port forwarding} in SSH
  303. The SSH protocol has the ability to forward arbitrary \I{network
  304. connection}network (TCP) connections over your encrypted SSH
  305. connection, to avoid the network traffic being sent in clear. For
  306. example, you could use this to connect from your home computer to a
  307. \i{POP-3} server on a remote machine without your POP-3 password being
  308. visible to network sniffers.
  309. In order to use port forwarding to \I{local port forwarding}connect
  310. from your local machine to a port on a remote server, you need to:
  311. \b Choose a \i{port number} on your local machine where PuTTY should
  312. listen for incoming connections. There are likely to be plenty of
  313. unused port numbers above 3000. (You can also use a local loopback
  314. address here; see below for more details.)
  315. \b Now, before you start your SSH connection, go to the Tunnels
  316. panel (see \k{config-ssh-portfwd}). Make sure the \q{Local} radio
  317. button is set. Enter the local port number into the \q{Source port}
  318. box. Enter the destination host name and port number into the
  319. \q{Destination} box, separated by a colon (for example,
  320. \c{popserver.example.com:110} to connect to a POP-3 server).
  321. \b Now click the \q{Add} button. The details of your port forwarding
  322. should appear in the list box.
  323. Now start your session and log in. (Port forwarding will not be
  324. enabled until after you have logged in; otherwise it would be easy
  325. to perform completely anonymous network attacks, and gain access to
  326. anyone's virtual private network.) To check that PuTTY has set up
  327. the port forwarding correctly, you can look at the PuTTY Event Log
  328. (see \k{using-eventlog}). It should say something like this:
  329. \c 2001-12-05 17:22:10 Local port 3110 forwarding to
  330. \c popserver.example.com:110
  331. Now if you connect to the source port number on your local PC, you
  332. should find that it answers you exactly as if it were the service
  333. running on the destination machine. So in this example, you could
  334. then configure an e-mail client to use \c{localhost:3110} as a POP-3
  335. server instead of \c{popserver.example.com:110}. (Of course, the
  336. forwarding will stop happening when your PuTTY session closes down.)
  337. You can also forward ports in the other direction: arrange for a
  338. particular port number on the \e{server} machine to be \I{remote
  339. port forwarding}forwarded back to your PC as a connection to a
  340. service on your PC or near it.
  341. To do this, just select the \q{Remote} radio button instead of the
  342. \q{Local} one. The \q{Source port} box will now specify a port
  343. number on the \e{server} (note that most servers will not allow you
  344. to use \I{privileged port}port numbers under 1024 for this purpose).
  345. An alternative way to forward local connections to remote hosts is
  346. to use \I{dynamic port forwarding}dynamic SOCKS proxying. In this
  347. mode, PuTTY acts as a SOCKS server, which SOCKS-aware programs can
  348. connect to and open forwarded connections to the destination of their
  349. choice, so this can be an alternative to long lists of static
  350. forwardings. To use this mode, you will need to select the \q{Dynamic}
  351. radio button instead of \q{Local}, and then you should not enter
  352. anything into the \q{Destination} box (it will be ignored). PuTTY will
  353. then listen for SOCKS connections on the port you have specified.
  354. Most \i{web browsers} can be configured to connect to this SOCKS proxy
  355. service; also, you can forward other PuTTY connections through it by
  356. setting up the Proxy control panel (see \k{config-proxy} for details).
  357. The source port for a forwarded connection usually does not accept
  358. connections from any machine except the \I{localhost}SSH client or
  359. server machine itself (for local and remote forwardings respectively).
  360. There are controls in the Tunnels panel to change this:
  361. \b The \q{Local ports accept connections from other hosts} option
  362. allows you to set up local-to-remote port forwardings (including
  363. dynamic port forwardings) in such a way that machines other than
  364. your client PC can connect to the forwarded port.
  365. \b The \q{Remote ports do the same} option does the same thing for
  366. remote-to-local port forwardings (so that machines other than the
  367. SSH server machine can connect to the forwarded port.) Note that
  368. this feature is only available in the SSH-2 protocol, and not all
  369. SSH-2 servers honour it (in \i{OpenSSH}, for example, it's usually
  370. disabled by default).
  371. You can also specify an \i{IP address} to \I{listen address}listen
  372. on. Typically a Windows machine can be asked to listen on any single
  373. IP address in the \cw{127.*.*.*} range, and all of these are
  374. \i{loopback address}es available only to the local machine. So if
  375. you forward (for example) \c{127.0.0.5:79} to a remote machine's
  376. \i\cw{finger} port, then you should be able to run commands such as
  377. \c{finger fred@127.0.0.5}.
  378. This can be useful if the program connecting to the forwarded port
  379. doesn't allow you to change the port number it uses. This feature is
  380. available for local-to-remote forwarded ports; SSH-1 is unable to
  381. support it for remote-to-local ports, while SSH-2 can support it in
  382. theory but servers will not necessarily cooperate.
  383. (Note that if you're using Windows XP Service Pack 2, you may need
  384. to obtain a fix from Microsoft in order to use addresses like
  385. \cw{127.0.0.5} - see \k{faq-alternate-localhost}.)
  386. For more options relating to port forwarding, see
  387. \k{config-ssh-portfwd}.
  388. If the connection you are forwarding over SSH is itself a second SSH
  389. connection made by another copy of PuTTY, you might find the
  390. \q{logical host name} configuration option useful to warn PuTTY of
  391. which host key it should be expecting. See \k{config-loghost} for
  392. details of this.
  393. \H{using-rawprot} Making \i{raw TCP connections}
  394. A lot of \I{debugging Internet protocols}Internet protocols are
  395. composed of commands and responses in plain text. For example,
  396. \i{SMTP} (the protocol used to transfer e-mail), \i{NNTP} (the
  397. protocol used to transfer Usenet news), and \i{HTTP} (the protocol
  398. used to serve Web pages) all consist of commands in readable plain
  399. text.
  400. Sometimes it can be useful to connect directly to one of these
  401. services and speak the protocol \q{by hand}, by typing protocol
  402. commands and watching the responses. On Unix machines, you can do
  403. this using the system's \c{telnet} command to connect to the right
  404. port number. For example, \c{telnet mailserver.example.com 25} might
  405. enable you to talk directly to the SMTP service running on a mail
  406. server.
  407. Although the Unix \c{telnet} program provides this functionality,
  408. the protocol being used is not really Telnet. Really there is no
  409. actual protocol at all; the bytes sent down the connection are
  410. exactly the ones you type, and the bytes shown on the screen are
  411. exactly the ones sent by the server. Unix \c{telnet} will attempt to
  412. detect or guess whether the service it is talking to is a real
  413. Telnet service or not; PuTTY prefers to be told for certain.
  414. In order to make a debugging connection to a service of this type,
  415. you simply select the fourth protocol name, \I{\q{Raw}
  416. protocol}\q{Raw}, from the \q{Protocol} buttons in the \q{Session}
  417. configuration panel. (See \k{config-hostname}.) You can then enter a
  418. host name and a port number, and make the connection.
  419. \H{using-serial} Connecting to a local serial line
  420. PuTTY can connect directly to a local serial line as an alternative
  421. to making a network connection. In this mode, text typed into the
  422. PuTTY window will be sent straight out of your computer's serial
  423. port, and data received through that port will be displayed in the
  424. PuTTY window. You might use this mode, for example, if your serial
  425. port is connected to another computer which has a serial connection.
  426. To make a connection of this type, simply select \q{Serial} from the
  427. \q{Connection type} radio buttons on the \q{Session} configuration
  428. panel (see \k{config-hostname}). The \q{Host Name} and \q{Port}
  429. boxes will transform into \q{Serial line} and \q{Speed}, allowing
  430. you to specify which serial line to use (if your computer has more
  431. than one) and what speed (baud rate) to use when transferring data.
  432. For further configuration options (data bits, stop bits, parity,
  433. flow control), you can use the \q{Serial} configuration panel (see
  434. \k{config-serial}).
  435. After you start up PuTTY in serial mode, you might find that you
  436. have to make the first move, by sending some data out of the serial
  437. line in order to notify the device at the other end that someone is
  438. there for it to talk to. This probably depends on the device. If you
  439. start up a PuTTY serial session and nothing appears in the window,
  440. try pressing Return a few times and see if that helps.
  441. A serial line provides no well defined means for one end of the
  442. connection to notify the other that the connection is finished.
  443. Therefore, PuTTY in serial mode will remain connected until you
  444. close the window using the close button.
  445. \H{using-cmdline} The PuTTY command line
  446. PuTTY can be made to do various things without user intervention by
  447. supplying \i{command-line arguments} (e.g., from a \i{command prompt
  448. window}, or a \i{Windows shortcut}).
  449. \S{using-cmdline-session} Starting a session from the command line
  450. \I\c{-ssh}\I\c{-telnet}\I\c{-rlogin}\I\c{-raw}\I\c{-serial}These
  451. options allow you to bypass the configuration window and launch
  452. straight into a session.
  453. To start a connection to a server called \c{host}:
  454. \c putty.exe [-ssh | -telnet | -rlogin | -raw] [user@]host
  455. If this syntax is used, settings are taken from the \i{Default Settings}
  456. (see \k{config-saving}); \c{user} overrides these settings if
  457. supplied. Also, you can specify a protocol, which will override the
  458. default protocol (see \k{using-cmdline-protocol}).
  459. For telnet sessions, the following alternative syntax is supported
  460. (this makes PuTTY suitable for use as a URL handler for \i{telnet
  461. URLs} in \i{web browsers}):
  462. \c putty.exe telnet://host[:port]/
  463. To start a connection to a serial port, e.g. COM1:
  464. \c putty.exe -serial com1
  465. In order to start an existing saved session called \c{sessionname},
  466. use the \c{-load} option (described in \k{using-cmdline-load}).
  467. \c putty.exe -load "session name"
  468. \S{using-cleanup} \i\c{-cleanup}
  469. \cfg{winhelp-topic}{options.cleanup}
  470. If invoked with the \c{-cleanup} option, rather than running as
  471. normal, PuTTY will remove its \I{removing registry entries}registry
  472. entries and \i{random seed file} from the local machine (after
  473. confirming with the user).
  474. Note that on \i{multi-user systems}, \c{-cleanup} only removes
  475. registry entries and files associated with the currently logged-in
  476. user.
  477. \S{using-general-opts} Standard command-line options
  478. PuTTY and its associated tools support a range of command-line
  479. options, most of which are consistent across all the tools. This
  480. section lists the available options in all tools. Options which are
  481. specific to a particular tool are covered in the chapter about that
  482. tool.
  483. \S2{using-cmdline-load} \i\c{-load}: load a saved session
  484. \I{saved sessions, loading from command line}The \c{-load} option
  485. causes PuTTY to load configuration details out of a saved session.
  486. If these details include a host name, then this option is all you
  487. need to make PuTTY start a session.
  488. You need double quotes around the session name if it contains spaces.
  489. If you want to create a \i{Windows shortcut} to start a PuTTY saved
  490. session, this is the option you should use: your shortcut should
  491. call something like
  492. \c d:\path\to\putty.exe -load "my session"
  493. (Note that PuTTY itself supports an alternative form of this option,
  494. for backwards compatibility. If you execute \i\c{putty @sessionname}
  495. it will have the same effect as \c{putty -load "sessionname"}. With
  496. the \c{@} form, no double quotes are required, and the \c{@} sign
  497. must be the very first thing on the command line. This form of the
  498. option is deprecated.)
  499. \S2{using-cmdline-protocol} Selecting a protocol: \c{-ssh},
  500. \c{-telnet}, \c{-rlogin}, \c{-raw} \c{-serial}
  501. To choose which protocol you want to connect with, you can use one
  502. of these options:
  503. \b \i\c{-ssh} selects the SSH protocol.
  504. \b \i\c{-telnet} selects the Telnet protocol.
  505. \b \i\c{-rlogin} selects the Rlogin protocol.
  506. \b \i\c{-raw} selects the raw protocol.
  507. \b \i\c{-serial} selects a serial connection.
  508. These options are not available in the file transfer tools PSCP and
  509. PSFTP (which only work with the SSH protocol).
  510. These options are equivalent to the \i{protocol selection} buttons
  511. in the Session panel of the PuTTY configuration box (see
  512. \k{config-hostname}).
  513. \S2{using-cmdline-v} \i\c{-v}: increase verbosity
  514. \I{verbose mode}Most of the PuTTY tools can be made to tell you more
  515. about what they are doing by supplying the \c{-v} option. If you are
  516. having trouble when making a connection, or you're simply curious,
  517. you can turn this switch on and hope to find out more about what is
  518. happening.
  519. \S2{using-cmdline-l} \i\c{-l}: specify a \i{login name}
  520. You can specify the user name to log in as on the remote server
  521. using the \c{-l} option. For example, \c{plink login.example.com -l
  522. fred}.
  523. These options are equivalent to the username selection box in the
  524. Connection panel of the PuTTY configuration box (see
  525. \k{config-username}).
  526. \S2{using-cmdline-portfwd} \I{-L-upper}\c{-L}, \I{-R-upper}\c{-R}
  527. and \I{-D-upper}\c{-D}: set up \i{port forwardings}
  528. As well as setting up port forwardings in the PuTTY configuration
  529. (see \k{config-ssh-portfwd}), you can also set up forwardings on the
  530. command line. The command-line options work just like the ones in
  531. Unix \c{ssh} programs.
  532. To \I{local port forwarding}forward a local port (say 5110) to a
  533. remote destination (say \cw{popserver.example.com} port 110), you
  534. can write something like one of these:
  535. \c putty -L 5110:popserver.example.com:110 -load mysession
  536. \c plink mysession -L 5110:popserver.example.com:110
  537. To forward a \I{remote port forwarding}remote port to a local
  538. destination, just use the \c{-R} option instead of \c{-L}:
  539. \c putty -R 5023:mytelnetserver.myhouse.org:23 -load mysession
  540. \c plink mysession -R 5023:mytelnetserver.myhouse.org:23
  541. To \I{listen address}specify an IP address for the listening end of the
  542. tunnel, prepend it to the argument:
  543. \c plink -L 127.0.0.5:23:localhost:23 myhost
  544. To set up \I{dynamic port forwarding}SOCKS-based dynamic port
  545. forwarding on a local port, use the \c{-D} option. For this one you
  546. only have to pass the port number:
  547. \c putty -D 4096 -load mysession
  548. For general information on port forwarding, see
  549. \k{using-port-forwarding}.
  550. These options are not available in the file transfer tools PSCP and
  551. PSFTP.
  552. \S2{using-cmdline-m} \i\c{-m}: \I{reading commands from a file}read
  553. a remote command or script from a file
  554. The \i\c{-m} option performs a similar function to the \q{\ii{Remote
  555. command}} box in the SSH panel of the PuTTY configuration box (see
  556. \k{config-command}). However, the \c{-m} option expects to be given
  557. a local file name, and it will read a command from that file.
  558. With some servers (particularly Unix systems), you can even put
  559. multiple lines in this file and execute more than one command in
  560. sequence, or a whole shell script; but this is arguably an abuse, and
  561. cannot be expected to work on all servers. In particular, it is known
  562. \e{not} to work with certain \q{embedded} servers, such as \i{Cisco}
  563. routers.
  564. This option is not available in the file transfer tools PSCP and
  565. PSFTP.
  566. \S2{using-cmdline-p} \I{-P-upper}\c{-P}: specify a \i{port number}
  567. The \c{-P} option is used to specify the port number to connect to. If
  568. you have a Telnet server running on port 9696 of a machine instead of
  569. port 23, for example:
  570. \c putty -telnet -P 9696 host.name
  571. \c plink -telnet -P 9696 host.name
  572. (Note that this option is more useful in Plink than in PuTTY,
  573. because in PuTTY you can write \c{putty -telnet host.name 9696} in
  574. any case.)
  575. This option is equivalent to the port number control in the Session
  576. panel of the PuTTY configuration box (see \k{config-hostname}).
  577. \S2{using-cmdline-pw} \i\c{-pw}: specify a \i{password}
  578. A simple way to automate a remote login is to supply your password
  579. on the command line. This is \e{not recommended} for reasons of
  580. security. If you possibly can, we recommend you set up public-key
  581. authentication instead. See \k{pubkey} for details.
  582. Note that the \c{-pw} option only works when you are using the SSH
  583. protocol. Due to fundamental limitations of Telnet and Rlogin, these
  584. protocols do not support automated password authentication.
  585. \S2{using-cmdline-agentauth} \i\c{-agent} and \i\c{-noagent}:
  586. control use of Pageant for authentication
  587. The \c{-agent} option turns on SSH authentication using Pageant, and
  588. \c{-noagent} turns it off. These options are only meaningful if you
  589. are using SSH.
  590. See \k{pageant} for general information on \i{Pageant}.
  591. These options are equivalent to the agent authentication checkbox in
  592. the Auth panel of the PuTTY configuration box (see
  593. \k{config-ssh-tryagent}).
  594. \S2{using-cmdline-agent} \I{-A-upper}\c{-A} and \i\c{-a}: control \i{agent
  595. forwarding}
  596. The \c{-A} option turns on SSH agent forwarding, and \c{-a} turns it
  597. off. These options are only meaningful if you are using SSH.
  598. See \k{pageant} for general information on \i{Pageant}, and
  599. \k{pageant-forward} for information on agent forwarding. Note that
  600. there is a security risk involved with enabling this option; see
  601. \k{pageant-security} for details.
  602. These options are equivalent to the agent forwarding checkbox in the
  603. Auth panel of the PuTTY configuration box (see \k{config-ssh-agentfwd}).
  604. These options are not available in the file transfer tools PSCP and
  605. PSFTP.
  606. \S2{using-cmdline-x11} \I{-X-upper}\c{-X} and \i\c{-x}: control \i{X11
  607. forwarding}
  608. The \c{-X} option turns on X11 forwarding in SSH, and \c{-x} turns
  609. it off. These options are only meaningful if you are using SSH.
  610. For information on X11 forwarding, see \k{using-x-forwarding}.
  611. These options are equivalent to the X11 forwarding checkbox in the
  612. X11 panel of the PuTTY configuration box (see \k{config-ssh-x11}).
  613. These options are not available in the file transfer tools PSCP and
  614. PSFTP.
  615. \S2{using-cmdline-pty} \i\c{-t} and \I{-T-upper}\c{-T}: control
  616. \i{pseudo-terminal allocation}
  617. The \c{-t} option ensures PuTTY attempts to allocate a
  618. pseudo-terminal at the server, and \c{-T} stops it from allocating
  619. one. These options are only meaningful if you are using SSH.
  620. These options are equivalent to the \q{Don't allocate a
  621. pseudo-terminal} checkbox in the SSH panel of the PuTTY
  622. configuration box (see \k{config-ssh-pty}).
  623. These options are not available in the file transfer tools PSCP and
  624. PSFTP.
  625. \S2{using-cmdline-noshell} \I{-N-upper}\c{-N}: suppress starting a
  626. \I{suppressing remote shell}shell or command
  627. The \c{-N} option prevents PuTTY from attempting to start a shell or
  628. command on the remote server. You might want to use this option if
  629. you are only using the SSH connection for port forwarding, and your
  630. user account on the server does not have the ability to run a shell.
  631. This feature is only available in SSH protocol version 2 (since the
  632. version 1 protocol assumes you will always want to run a shell).
  633. This option is equivalent to the \q{Don't start a shell or command
  634. at all} checkbox in the SSH panel of the PuTTY configuration box
  635. (see \k{config-ssh-noshell}).
  636. This option is not available in the file transfer tools PSCP and
  637. PSFTP.
  638. \S2{using-cmdline-ncmode} \I{-nc}\c{-nc}: make a \i{remote network
  639. connection} in place of a remote shell or command
  640. The \c{-nc} option prevents Plink (or PuTTY) from attempting to
  641. start a shell or command on the remote server. Instead, it will
  642. instruct the remote server to open a network connection to a host
  643. name and port number specified by you, and treat that network
  644. connection as if it were the main session.
  645. You specify a host and port as an argument to the \c{-nc} option,
  646. with a colon separating the host name from the port number, like
  647. this:
  648. \c plink host1.example.com -nc host2.example.com:1234
  649. You might want to use this feature if you needed to make an SSH
  650. connection to a target host which you can only reach by going
  651. through a proxy host, and rather than using port forwarding you
  652. prefer to use the local proxy feature (see \k{config-proxy-type} for
  653. more about local proxies). In this situation you might select
  654. \q{Local} proxy type, set your local proxy command to be \cq{plink
  655. %proxyhost -nc %host:%port}, enter the target host name on the
  656. Session panel, and enter the directly reachable proxy host name on
  657. the Proxy panel.
  658. This feature is only available in SSH protocol version 2 (since the
  659. version 1 protocol assumes you will always want to run a shell). It
  660. is not available in the file transfer tools PSCP and PSFTP. It is
  661. available in PuTTY itself, although it is unlikely to be very useful
  662. in any tool other than Plink. Also, \c{-nc} uses the same server
  663. functionality as port forwarding, so it will not work if your server
  664. administrator has disabled port forwarding.
  665. (The option is named \c{-nc} after the Unix program
  666. \W{http://www.vulnwatch.org/netcat/}\c{nc}, short for \q{netcat}.
  667. The command \cq{plink host1 -nc host2:port} is very similar in
  668. functionality to \cq{plink host1 nc host2 port}, which invokes
  669. \c{nc} on the server and tells it to connect to the specified
  670. destination. However, Plink's built-in \c{-nc} option does not
  671. depend on the \c{nc} program being installed on the server.)
  672. \S2{using-cmdline-compress} \I{-C-upper}\c{-C}: enable \i{compression}
  673. The \c{-C} option enables compression of the data sent across the
  674. network. This option is only meaningful if you are using SSH.
  675. This option is equivalent to the \q{Enable compression} checkbox in
  676. the SSH panel of the PuTTY configuration box (see
  677. \k{config-ssh-comp}).
  678. \S2{using-cmdline-sshprot} \i\c{-1} and \i\c{-2}: specify an \i{SSH
  679. protocol version}
  680. The \c{-1} and \c{-2} options force PuTTY to use version \I{SSH-1}1
  681. or version \I{SSH-2}2 of the SSH protocol. These options are only
  682. meaningful if you are using SSH.
  683. These options are equivalent to selecting the SSH protocol version in
  684. the SSH panel of the PuTTY configuration box (see \k{config-ssh-prot}).
  685. \S2{using-cmdline-ipversion} \i\c{-4} and \i\c{-6}: specify an
  686. \i{Internet protocol version}
  687. The \c{-4} and \c{-6} options force PuTTY to use the older Internet
  688. protocol \i{IPv4} or the newer \i{IPv6} for most outgoing
  689. connections.
  690. These options are equivalent to selecting your preferred Internet
  691. protocol version as \q{IPv4} or \q{IPv6} in the Connection panel of
  692. the PuTTY configuration box (see \k{config-address-family}).
  693. \S2{using-cmdline-identity} \i\c{-i}: specify an SSH \i{private key}
  694. The \c{-i} option allows you to specify the name of a private key
  695. file in \c{*.\i{PPK}} format which PuTTY will use to authenticate with the
  696. server. This option is only meaningful if you are using SSH.
  697. If you are using Pageant, you can also specify a \e{public} key file
  698. (in RFC 4716 or OpenSSH format) to identify a specific key file to use.
  699. (This won't work if you're not running Pageant, of course.)
  700. For general information on \i{public-key authentication}, see
  701. \k{pubkey}.
  702. This option is equivalent to the \q{Private key file for
  703. authentication} box in the Auth panel of the PuTTY configuration box
  704. (see \k{config-ssh-privkey}).
  705. \S2{using-cmdline-loghost} \i\c{-loghost}: specify a \i{logical host
  706. name}
  707. This option overrides PuTTY's normal SSH \I{host key cache}host key
  708. caching policy by telling it the name of the host you expect your
  709. connection to end up at (in cases where this differs from the location
  710. PuTTY thinks it's connecting to). It can be a plain host name, or a
  711. host name followed by a colon and a port number. See
  712. \k{config-loghost} for more detail on this.
  713. \S2{using-cmdline-hostkey} \i\c{-hostkey}: \I{manually configuring
  714. host keys}manually specify an expected host key
  715. This option overrides PuTTY's normal SSH \I{host key cache}host key
  716. caching policy by telling it exactly what host key to expect, which
  717. can be useful if the normal automatic host key store in the Registry
  718. is unavailable. The argument to this option should be either a host key
  719. fingerprint, or an SSH-2 public key blob. See
  720. \k{config-ssh-kex-manual-hostkeys} for more information.
  721. You can specify this option more than once if you want to configure
  722. more than one key to be accepted.
  723. \S2{using-cmdline-pgpfp} \i\c{-pgpfp}: display \i{PGP key fingerprint}s
  724. This option causes the PuTTY tools not to run as normal, but instead
  725. to display the fingerprints of the PuTTY PGP Master Keys, in order to
  726. aid with \i{verifying new versions}. See \k{pgpkeys} for more information.
  727. \S2{using-cmdline-sercfg} \i\c{-sercfg}: specify serial port
  728. \i{configuration}
  729. This option specifies the configuration parameters for the serial
  730. port (baud rate, stop bits etc). Its argument is interpreted as a
  731. comma-separated list of configuration options, which can be as
  732. follows:
  733. \b Any single digit from 5 to 9 sets the number of data bits.
  734. \b \cq{1}, \cq{1.5} or \cq{2} sets the number of stop bits.
  735. \b Any other numeric string is interpreted as a baud rate.
  736. \b A single lower-case letter specifies the parity: \cq{n} for none,
  737. \cq{o} for odd, \cq{e} for even, \cq{m} for mark and \cq{s} for space.
  738. \b A single upper-case letter specifies the flow control: \cq{N} for
  739. none, \cq{X} for XON/XOFF, \cq{R} for RTS/CTS and \cq{D} for
  740. DSR/DTR.
  741. For example, \cq{-sercfg 19200,8,n,1,N} denotes a baud rate of
  742. 19200, 8 data bits, no parity, 1 stop bit and no flow control.
  743. \S2{using-cmdline-sshlog} \i\c{-sessionlog}, \i\c{-sshlog},
  744. \i\c{-sshrawlog}: specify session logging
  745. These options cause the PuTTY network tools to write out a \i{log
  746. file}. Each of them expects a file name as an argument, e.g.
  747. \cq{-sshlog putty.log} causes an SSH packet log to be written to a
  748. file called \cq{putty.log}. The three different options select
  749. different logging modes, all available from the GUI too:
  750. \b \c{-sessionlog} selects \q{All session output} logging mode.
  751. \b \c{-sshlog} selects \q{SSH packets} logging mode.
  752. \b \c{-sshrawlog} selects \q{SSH packets and raw data} logging mode.
  753. For more information on logging configuration, see \k{config-logging}.