pageant.but 12 KB

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