pageant.but 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  1. \C{pageant} Using \i{Pageant} for authentication
  2. \cfg{winhelp-topic}{pageant.general}
  3. Pageant is an SSH \i{authentication agent}. It holds your \i{private key}s
  4. in memory, already decoded, so that you can use them often
  5. \I{passwordless login}without needing to type a \i{passphrase}.
  6. \H{pageant-start} Getting started with Pageant
  7. Before you run Pageant, you need to have a private key in \c{*.\i{PPK}}
  8. format. See \k{pubkey} to find out how to generate and use one.
  9. When you run Pageant, it will put an icon of a computer wearing a
  10. hat into the \ii{System tray}. It will then sit and do nothing, until you
  11. load a private key into it.
  12. If you click the Pageant icon with the right mouse button, you will
  13. see a menu. Select \q{View Keys} from this menu. The Pageant main
  14. window will appear. (You can also bring this window up by
  15. double-clicking on the Pageant icon.)
  16. The Pageant window contains a list box. This shows the private keys
  17. Pageant is holding. When you start Pageant, it has no keys, so the
  18. list box will be empty. After you add one or more keys, they will
  19. show up in the list box.
  20. To add a key to Pageant, press the \q{Add Key} button. Pageant will
  21. bring up a file dialog, labelled \q{Select Private Key File}. Find
  22. your private key file in this dialog, and press \q{Open}.
  23. Pageant will now load the private key. If the key is protected by a
  24. passphrase, Pageant will ask you to type the passphrase. When the
  25. key has been loaded, it will appear in the list in the Pageant
  26. window.
  27. Now start PuTTY and open an SSH session to a site that accepts your
  28. key. PuTTY will notice that Pageant is running, retrieve the key
  29. automatically from Pageant, and use it to authenticate. You can now
  30. open as many PuTTY sessions as you like without having to type your
  31. passphrase again.
  32. (PuTTY can be configured not to try to use Pageant, but it will try
  33. by default. See \k{config-ssh-tryagent} and
  34. \k{using-cmdline-agentauth} for more information.)
  35. When you want to shut down Pageant, click the right button on the
  36. Pageant icon in the System tray, and select \q{Exit} from the menu.
  37. Closing the Pageant main window does \e{not} shut down Pageant.
  38. \H{pageant-mainwin} The Pageant main window
  39. The Pageant main window appears when you left-click on the Pageant
  40. system tray icon, or alternatively right-click and select \q{View
  41. Keys} from the menu. You can use it to keep track of what keys are
  42. currently loaded into Pageant, and to add new ones or remove the
  43. existing keys.
  44. \S{pageant-mainwin-keylist} The key list box
  45. \cfg{winhelp-topic}{pageant.keylist}
  46. The large list box in the Pageant main window lists the private keys
  47. that are currently loaded into Pageant. The list might look
  48. something like this:
  49. \c ssh-rsa 2048 22:d6:69:c9:22:51:ac:cb:b9:15:67:47:f7:65:6d:d7 k1
  50. \c ssh-dss 2048 e4:6c:69:f3:4f:fc:cf:fc:96:c0:88:34:a7:1e:59:d7 k2
  51. For each key, the list box will tell you:
  52. \b The type of the key. Currently, this can be \c{ssh1} (an RSA key
  53. for use with the SSH-1 protocol), \c{ssh-rsa} (an RSA key for use
  54. with the SSH-2 protocol), \c{ssh-dss} (a DSA key for use with
  55. the SSH-2 protocol), \c{ecdsa-sha2-*} (an ECDSA key for use with
  56. the SSH-2 protocol), or \c{ssh-ed25519} (an Ed25519 key for use with
  57. the SSH-2 protocol).
  58. \b The size (in bits) of the key.
  59. \b The \I{key fingerprint}fingerprint for the public key. This should be
  60. the same fingerprint given by PuTTYgen, and (hopefully) also the same
  61. fingerprint shown by remote utilities such as \i\c{ssh-keygen} when
  62. applied to your \c{authorized_keys} file.
  63. \b The comment attached to the key.
  64. \S{pageant-mainwin-addkey} The \q{Add Key} button
  65. \cfg{winhelp-topic}{pageant.addkey}
  66. To add a key to Pageant by reading it out of a local disk file,
  67. press the \q{Add Key} button in the Pageant main window, or
  68. alternatively right-click on the Pageant icon in the system tray and
  69. select \q{Add Key} from there.
  70. Pageant will bring up a file dialog, labelled \q{Select Private Key
  71. File}. Find your private key file in this dialog, and press
  72. \q{Open}. If you want to add more than one key at once, you can
  73. select multiple files using Shift-click (to select several adjacent
  74. files) or Ctrl-click (to select non-adjacent files).
  75. Pageant will now load the private key(s). If a key is protected by a
  76. passphrase, Pageant will ask you to type the passphrase.
  77. (This is not the only way to add a private key to Pageant. You can
  78. also add one from a remote system by using agent forwarding; see
  79. \k{pageant-forward} for details.)
  80. \S{pageant-mainwin-remkey} The \q{Remove Key} button
  81. \cfg{winhelp-topic}{pageant.remkey}
  82. If you need to remove a key from Pageant, select that key in the
  83. list box, and press the \q{Remove Key} button. Pageant will remove
  84. the key from its memory.
  85. You can apply this to keys you added using the \q{Add Key} button,
  86. or to keys you added remotely using agent forwarding (see
  87. \k{pageant-forward}); it makes no difference.
  88. \H{pageant-cmdline} The Pageant command line
  89. Pageant can be made to do things automatically when it starts up, by
  90. \I{command-line arguments}specifying instructions on its command line.
  91. If you're starting Pageant from the Windows GUI, you can arrange this
  92. by editing the properties of the \i{Windows shortcut} that it was
  93. started from.
  94. If Pageant is already running, invoking it again with the options
  95. below causes actions to be performed with the existing instance, not a
  96. new one.
  97. \S{pageant-cmdline-loadkey} Making Pageant automatically load keys
  98. on startup
  99. Pageant can automatically load one or more private keys when it
  100. starts up, if you provide them on the Pageant command line. Your
  101. command line might then look like:
  102. \c C:\PuTTY\pageant.exe d:\main.ppk d:\secondary.ppk
  103. If the keys are stored encrypted, Pageant will request the
  104. passphrases on startup.
  105. If Pageant is already running, this syntax loads keys into the
  106. existing Pageant.
  107. \S{pageant-cmdline-command} Making Pageant run another program
  108. You can arrange for Pageant to start another program once it has
  109. initialised itself and loaded any keys specified on its command
  110. line. This program (perhaps a PuTTY, or a WinCVS making use of
  111. Plink, or whatever) will then be able to use the keys Pageant has
  112. loaded.
  113. You do this by specifying the \I{-c-pageant}\c{-c} option followed
  114. by the command, like this:
  115. \c C:\PuTTY\pageant.exe d:\main.ppk -c C:\PuTTY\putty.exe
  116. \H{pageant-forward} Using \i{agent forwarding}
  117. Agent forwarding is a mechanism that allows applications on your SSH
  118. server machine to talk to the agent on your client machine.
  119. Note that at present, agent forwarding in SSH-2 is only available
  120. when your SSH server is \i{OpenSSH}. The \i\cw{ssh.com} server uses a
  121. different agent protocol, which PuTTY does not yet support.
  122. To enable agent forwarding, first start Pageant. Then set up a PuTTY
  123. SSH session in which \q{Allow agent forwarding} is enabled (see
  124. \k{config-ssh-agentfwd}). Open the session as normal. (Alternatively,
  125. you can use the \c{-A} command line option; see
  126. \k{using-cmdline-agent} for details.)
  127. If this has worked, your applications on the server should now have
  128. access to a Unix domain socket which the SSH server will forward
  129. back to PuTTY, and PuTTY will forward on to the agent. To check that
  130. this has actually happened, you can try this command on Unix server
  131. machines:
  132. \c unixbox:~$ echo $SSH_AUTH_SOCK
  133. \c /tmp/ssh-XXNP18Jz/agent.28794
  134. \c unixbox:~$
  135. If the result line comes up blank, agent forwarding has not been
  136. enabled at all.
  137. Now if you run \c{ssh} on the server and use it to connect through
  138. to another server that accepts one of the keys in Pageant, you
  139. should be able to log in without a password:
  140. \c unixbox:~$ ssh -v otherunixbox
  141. \c [...]
  142. \c debug: next auth method to try is publickey
  143. \c debug: userauth_pubkey_agent: trying agent key my-putty-key
  144. \c debug: ssh-userauth2 successful: method publickey
  145. \c [...]
  146. If you enable agent forwarding on \e{that} SSH connection as well
  147. (see the manual for your server-side SSH client to find out how to
  148. do this), your authentication keys will still be available on the
  149. next machine you connect to - two SSH connections away from where
  150. they're actually stored.
  151. In addition, if you have a private key on one of the SSH servers,
  152. you can send it all the way back to Pageant using the local
  153. \i\c{ssh-add} command:
  154. \c unixbox:~$ ssh-add ~/.ssh/id_rsa
  155. \c Need passphrase for /home/fred/.ssh/id_rsa
  156. \c Enter passphrase for /home/fred/.ssh/id_rsa:
  157. \c Identity added: /home/fred/.ssh/id_rsa (/home/simon/.ssh/id_rsa)
  158. \c unixbox:~$
  159. and then it's available to every machine that has agent forwarding
  160. available (not just the ones downstream of the place you added it).
  161. \H{pageant-security} Security considerations
  162. \I{security risk}Using Pageant for public-key authentication gives you the
  163. convenience of being able to open multiple SSH sessions without
  164. having to type a passphrase every time, but also gives you the
  165. security benefit of never storing a decrypted private key on disk.
  166. Many people feel this is a good compromise between security and
  167. convenience.
  168. It \e{is} a compromise, however. Holding your decrypted private keys
  169. in Pageant is better than storing them in easy-to-find disk files,
  170. but still less secure than not storing them anywhere at all. This is
  171. for two reasons:
  172. \b Windows unfortunately provides no way to protect pieces of memory
  173. from being written to the system \i{swap file}. So if Pageant is holding
  174. your private keys for a long period of time, it's possible that
  175. decrypted private key data may be written to the system swap file,
  176. and an attacker who gained access to your hard disk later on might
  177. be able to recover that data. (However, if you stored an unencrypted
  178. key in a disk file they would \e{certainly} be able to recover it.)
  179. \b Although, like most modern operating systems, Windows prevents
  180. programs from accidentally accessing one another's memory space, it
  181. does allow programs to access one another's memory space
  182. deliberately, for special purposes such as debugging. This means
  183. that if you allow a virus, trojan, or other malicious program on to
  184. your Windows system while Pageant is running, it could access the
  185. memory of the Pageant process, extract your decrypted authentication
  186. keys, and send them back to its master.
  187. Similarly, use of agent \e{forwarding} is a security improvement on
  188. other methods of one-touch authentication, but not perfect. Holding
  189. your keys in Pageant on your Windows box has a security advantage
  190. over holding them on the remote server machine itself (either in an
  191. agent or just unencrypted on disk), because if the server machine
  192. ever sees your unencrypted private key then the sysadmin or anyone
  193. who cracks the machine can steal the keys and pretend to be you for
  194. as long as they want.
  195. However, the sysadmin of the server machine can always pretend to be
  196. you \e{on that machine}. So if you forward your agent to a server
  197. machine, then the sysadmin of that machine can access the forwarded
  198. agent connection and request signatures from any of your private keys,
  199. and can therefore log in to other machines as you. They can only do
  200. this to a limited extent - when the agent forwarding disappears they
  201. lose the ability - but using Pageant doesn't actually \e{prevent} the
  202. sysadmin (or hackers) on the server from doing this.
  203. Therefore, if you don't trust the sysadmin of a server machine, you
  204. should \e{never} use agent forwarding to that machine. (Of course
  205. you also shouldn't store private keys on that machine, type
  206. passphrases into it, or log into other machines from it in any way
  207. at all; Pageant is hardly unique in this respect.)