pageant.but 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346
  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. (You may need to use Windows'
  11. \q{Show hidden icons} arrow to see the Pageant icon.)
  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. If you want Pageant to stay running but forget all the keys it has
  39. acquired, select \q{Remove All Keys} from the System tray menu.
  40. \H{pageant-mainwin} The Pageant main window
  41. The Pageant main window appears when you left-click on the Pageant
  42. system tray icon, or alternatively right-click and select \q{View
  43. Keys} from the menu. You can use it to keep track of what keys are
  44. currently loaded into Pageant, and to add new ones or remove the
  45. existing keys.
  46. \S{pageant-mainwin-keylist} The key list box
  47. The large list box in the Pageant main window lists the private keys
  48. that are currently loaded into Pageant. The list might look
  49. something like this:
  50. \c ssh-ed25519 SHA256:TddlQk20DVs4LRcAsIfDN9pInKpY06D+h4kSHwWAj4w
  51. \c ssh-rsa 2048 SHA256:8DFtyHm3kQihgy52nzX96qMcEVOq7/yJmmwQQhBWYFg
  52. For each key, the list box will tell you:
  53. \b The type of the key. Currently, this can be
  54. \c{ssh-rsa} (an RSA key for use with the SSH-2 protocol),
  55. \c{ssh-dss} (a DSA key for use with the SSH-2 protocol),
  56. \c{ecdsa-sha2-*} (an ECDSA key for use with the SSH-2 protocol),
  57. \c{ssh-ed25519} (an Ed25519 key for use with the SSH-2 protocol),
  58. \c{ssh-ed448} (an Ed448 key for use with the SSH-2 protocol),
  59. or \c{ssh1} (an RSA key for use with the old SSH-1 protocol).
  60. \b The size (in bits) of the key, for key types that come in different
  61. sizes.
  62. \b The \I{key fingerprint}fingerprint for the public key. This should be
  63. the same fingerprint given by PuTTYgen, and (hopefully) also the same
  64. fingerprint shown by remote utilities such as \i\c{ssh-keygen} when
  65. applied to your \c{authorized_keys} file.
  66. \lcont{
  67. By default this is shown in the \q{SHA256} format. You can change to the
  68. older \q{MD5} format (which looks like \c{aa:bb:cc:...}) with the
  69. \q{Fingerprint type} drop-down, but bear in mind that this format is
  70. less secure and should be avoided for comparison purposes where possible.
  71. }
  72. \b The comment attached to the key.
  73. \b The state of deferred decryption, if enabled for this key.
  74. See \k{pageant-deferred-decryption}.
  75. \S{pageant-mainwin-addkey} The \q{Add Key} button
  76. To add a key to Pageant by reading it out of a local disk file,
  77. press the \q{Add Key} button in the Pageant main window, or
  78. alternatively right-click on the Pageant icon in the system tray and
  79. select \q{Add Key} from there.
  80. Pageant will bring up a file dialog, labelled \q{Select Private Key
  81. File}. Find your private key file in this dialog, and press
  82. \q{Open}. If you want to add more than one key at once, you can
  83. select multiple files using Shift-click (to select several adjacent
  84. files) or Ctrl-click (to select non-adjacent files).
  85. Pageant will now load the private key(s). If a key is protected by a
  86. passphrase, Pageant will ask you to type the passphrase.
  87. (This is not the only way to add a private key to Pageant. You can
  88. also add one from a remote system by using agent forwarding; see
  89. \k{pageant-forward} for details.)
  90. \S{pageant-mainwin-remkey} The \q{Remove Key} button
  91. If you need to remove a key from Pageant, select that key in the
  92. list box, and press the \q{Remove Key} button. Pageant will remove
  93. the key from its memory.
  94. You can apply this to keys you added using the \q{Add Key} button,
  95. or to keys you added remotely using agent forwarding (see
  96. \k{pageant-forward}); it makes no difference.
  97. \H{pageant-cmdline} The Pageant command line
  98. Pageant can be made to do things automatically when it starts up, by
  99. \I{command-line arguments}specifying instructions on its command line.
  100. If you're starting Pageant from the Windows GUI, you can arrange this
  101. by editing the properties of the \i{Windows shortcut} that it was
  102. started from.
  103. If Pageant is already running, invoking it again with the options
  104. below causes actions to be performed with the existing instance, not a
  105. new one.
  106. \S{pageant-cmdline-loadkey} Making Pageant automatically load keys
  107. on startup
  108. Pageant can automatically load one or more private keys when it
  109. starts up, if you provide them on the Pageant command line. Your
  110. command line might then look like:
  111. \c C:\PuTTY\pageant.exe d:\main.ppk d:\secondary.ppk
  112. If the keys are stored encrypted, Pageant will request the
  113. passphrases on startup.
  114. If Pageant is already running, this syntax loads keys into the
  115. existing Pageant.
  116. You can specify the \cq{--encrypted} option to defer decryption of
  117. these keys; see \k{pageant-deferred-decryption}.
  118. \S{pageant-cmdline-command} Making Pageant run another program
  119. You can arrange for Pageant to start another program once it has
  120. initialised itself and loaded any keys specified on its command
  121. line. This program (perhaps a PuTTY, or a WinCVS making use of
  122. Plink, or whatever) will then be able to use the keys Pageant has
  123. loaded.
  124. You do this by specifying the \I{-c-pageant}\c{-c} option followed
  125. by the command, like this:
  126. \c C:\PuTTY\pageant.exe d:\main.ppk -c C:\PuTTY\putty.exe
  127. \S{pageant-cmdline-keylist} Starting with the key list visible
  128. Start Pageant with the \i\c{--keylist} option to show the main window
  129. as soon as it starts up.
  130. \S{pageant-cmdline-restrict-acl} Restricting the \i{Windows process ACL}
  131. Pageant supports the same \i\c{-restrict-acl} option as the other
  132. PuTTY utilities to lock down the Pageant process's access control;
  133. see \k{using-cmdline-restrict-acl} for why you might want to do this.
  134. By default, if Pageant is started with \c{-restrict-acl}, it won't
  135. pass this to any PuTTY sessions started from its System Tray submenu.
  136. Use \c{-restrict-putty-acl} to change this. (Again, see
  137. \k{using-cmdline-restrict-acl} for details.)
  138. \H{pageant-forward} Using \i{agent forwarding}
  139. Agent forwarding is a mechanism that allows applications on your SSH
  140. server machine to talk to the agent on your client machine.
  141. Note that at present, whether agent forwarding in SSH-2 is available
  142. depends on your server. Pageant's protocol is compatible with the
  143. \i{OpenSSH} server, but the \i\cw{ssh.com} server uses a different
  144. agent protocol, which PuTTY does not yet support.
  145. To enable agent forwarding, first start Pageant. Then set up a PuTTY
  146. SSH session in which \q{Allow agent forwarding} is enabled (see
  147. \k{config-ssh-agentfwd}). Open the session as normal. (Alternatively,
  148. you can use the \c{-A} command line option; see
  149. \k{using-cmdline-agent} for details.)
  150. If this has worked, your applications on the server should now have
  151. access to a Unix domain socket which the SSH server will forward
  152. back to PuTTY, and PuTTY will forward on to the agent. To check that
  153. this has actually happened, you can try this command on Unix server
  154. machines:
  155. \c unixbox:~$ echo $SSH_AUTH_SOCK
  156. \c /tmp/ssh-XXNP18Jz/agent.28794
  157. \c unixbox:~$
  158. If the result line comes up blank, agent forwarding has not been
  159. enabled at all.
  160. Now if you run \c{ssh} on the server and use it to connect through
  161. to another server that accepts one of the keys in Pageant, you
  162. should be able to log in without a password:
  163. \c unixbox:~$ ssh -v otherunixbox
  164. \c [...]
  165. \c debug: next auth method to try is publickey
  166. \c debug: userauth_pubkey_agent: trying agent key my-putty-key
  167. \c debug: ssh-userauth2 successful: method publickey
  168. \c [...]
  169. If you enable agent forwarding on \e{that} SSH connection as well
  170. (see the manual for your server-side SSH client to find out how to
  171. do this), your authentication keys will still be available on the
  172. next machine you connect to - two SSH connections away from where
  173. they're actually stored.
  174. In addition, if you have a private key on one of the SSH servers,
  175. you can send it all the way back to Pageant using the local
  176. \i\c{ssh-add} command:
  177. \c unixbox:~$ ssh-add ~/.ssh/id_rsa
  178. \c Need passphrase for /home/fred/.ssh/id_rsa
  179. \c Enter passphrase for /home/fred/.ssh/id_rsa:
  180. \c Identity added: /home/fred/.ssh/id_rsa (/home/simon/.ssh/id_rsa)
  181. \c unixbox:~$
  182. and then it's available to every machine that has agent forwarding
  183. available (not just the ones downstream of the place you added it).
  184. \H{pageant-deferred-decryption} Loading keys without decrypting them
  185. You can add keys to Pageant \e{without} decrypting them. The key
  186. file will be held in Pageant's memory still encrypted, and when a
  187. client program first tries to use the key, Pageant will display a
  188. dialog box prompting for the passphrase so that the key can be
  189. decrypted.
  190. This works the same way whether the key is used by an instance of
  191. PuTTY running locally, or a remote client connecting to Pageant
  192. through agent forwarding.
  193. To add a key to Pageant in this encrypted form, press the \q{Add Key
  194. (encrypted)} button in the Pageant main window, or alternatively
  195. right-click on the Pageant icon in the system tray and select \q{Add
  196. Key (encrypted)} from there. Pageant will bring up a file dialog, in
  197. just the same way as it would for the plain \q{Add Key} button. But it
  198. won't ask for a passphrase. Instead, the key will be listed in the
  199. main window with \q{(encrypted)} after it.
  200. To start Pageant up in the first place with encrypted keys loaded into
  201. it, you can use the \cq{--encrypted} option on the command line. For
  202. example:
  203. \c C:\PuTTY\pageant.exe --encrypted d:\main.ppk
  204. After a key has been decrypted for the first use, it remains
  205. decrypted, so that it can be used again. The main window will list
  206. the key with \q{(\i{re-encryptable})} after it. You can revert it
  207. to the previous state, where a passphrase is required, using the
  208. \q{\i{Re-encrypt}} button in the Pageant main window.
  209. You can also \q{re-encrypt} all keys that were added encrypted by
  210. choosing \q{Re-encrypt All Keys} from the System tray menu.
  211. (Note that this does \e{not} discard cleartext keys that were not
  212. previously added encrypted!)
  213. \s{CAUTION}: When Pageant displays a prompt to decrypt an
  214. already-loaded key, it cannot give keyboard focus to the prompt dialog
  215. box. As far as I know this is a deliberate defensive measure by
  216. Windows, against malicious software. So make sure you click in the
  217. prompt window before typing your passphrase, or else the passphrase
  218. might be sent to somewhere you didn't want to trust with it!
  219. \H{pageant-security} Security considerations
  220. \I{security risk}Using Pageant for public-key authentication gives you the
  221. convenience of being able to open multiple SSH sessions without
  222. having to type a passphrase every time, but also gives you the
  223. security benefit of never storing a decrypted private key on disk.
  224. Many people feel this is a good compromise between security and
  225. convenience.
  226. It \e{is} a compromise, however. Holding your decrypted private keys
  227. in Pageant is better than storing them in easy-to-find disk files,
  228. but still less secure than not storing them anywhere at all. This is
  229. for two reasons:
  230. \b Windows unfortunately provides no way to protect pieces of memory
  231. from being written to the system \i{swap file}. So if Pageant is holding
  232. your private keys for a long period of time, it's possible that
  233. decrypted private key data may be written to the system swap file,
  234. and an attacker who gained access to your hard disk later on might
  235. be able to recover that data. (However, if you stored an unencrypted
  236. key in a disk file they would \e{certainly} be able to recover it.)
  237. \b Although, like most modern operating systems, Windows prevents
  238. programs from accidentally accessing one another's memory space, it
  239. does allow programs to access one another's memory space
  240. deliberately, for special purposes such as debugging. This means
  241. that if you allow a virus, trojan, or other malicious program on to
  242. your Windows system while Pageant is running, it could access the
  243. memory of the Pageant process, extract your decrypted authentication
  244. keys, and send them back to its master.
  245. Similarly, use of agent \e{forwarding} is a security improvement on
  246. other methods of one-touch authentication, but not perfect. Holding
  247. your keys in Pageant on your Windows box has a security advantage
  248. over holding them on the remote server machine itself (either in an
  249. agent or just unencrypted on disk), because if the server machine
  250. ever sees your unencrypted private key then the sysadmin or anyone
  251. who cracks the machine can steal the keys and pretend to be you for
  252. as long as they want.
  253. However, the sysadmin of the server machine can always pretend to be
  254. you \e{on that machine}. So if you forward your agent to a server
  255. machine, then the sysadmin of that machine can access the forwarded
  256. agent connection and request signatures from any of your private keys,
  257. and can therefore log in to other machines as you. They can only do
  258. this to a limited extent - when the agent forwarding disappears they
  259. lose the ability - but using Pageant doesn't actually \e{prevent} the
  260. sysadmin (or hackers) on the server from doing this.
  261. Therefore, if you don't trust the sysadmin of a server machine, you
  262. should \e{never} use agent forwarding to that machine. (Of course
  263. you also shouldn't store private keys on that machine, type
  264. passphrases into it, or log into other machines from it in any way
  265. at all; Pageant is hardly unique in this respect.)