Differences

This shows you the differences between the selected revisions of the page.

public_key 2014-09-11 public_key 2023-08-01 (current)
Line 1: Line 1:
====== Using Public Keys for Authentication ====== ====== Using Public Keys for Authentication ======
-//This article explains public key authentication in general. You may want to see guide to [[guide_public_key|setting up public·key authentication]] instead.//+//This article explains public key authentication in general. You may want to see the guide to [[guide_public_key|setting up public-key authentication]] instead.//
-//Do not confuse your private/public key pair used for authentication with [[ssh_verifying_the_host_key|host public key verification]].//+//Do not confuse your user key pair used for authentication with [[ssh_verifying_the_host_key|host public key verification]]. Learn about [[ssh_keys|all SSH key types]].//
===== Introduction ===== ===== Introduction =====
Line 14: Line 14:
So you generate a key pair on your own computer, and you copy the public key to the server under a certain name. Then, when the server asks you to prove who you are, WinSCP can generate a signature using your private key. The server can verify that signature (since it has your public key) and allow you to log in. Now if the server is hacked or spoofed, the attacker does not gain your private key or password; they only gain one signature. And signatures cannot be re-used, so they have gained nothing. So you generate a key pair on your own computer, and you copy the public key to the server under a certain name. Then, when the server asks you to prove who you are, WinSCP can generate a signature using your private key. The server can verify that signature (since it has your public key) and allow you to log in. Now if the server is hacked or spoofed, the attacker does not gain your private key or password; they only gain one signature. And signatures cannot be re-used, so they have gained nothing.
-There is a problem with this: if your [[#private|private key]] is stored unprotected on your own computer, then anybody who gains access to that will be able to generate signatures as if they were you. So they will be able to log in to your server under your account. For this reason, your private key is usually encrypted when it is stored on your local machine, using a passphrase of your choice. In order to generate a signature, WinSCP must decrypt the key, so you have to type your passphrase.·+There is a problem with this: if your [[#private|private key]] is stored unprotected on your own computer, then anybody who gains access to that will be able to generate signatures as if they were you. So they will be able to log in to your server under your account. For this reason, your private key is usually encrypted when it is stored on your local machine, using a passphrase of your choice. In order to generate a signature, WinSCP must decrypt the key, so you have to type your passphrase.
This can make public-key authentication less convenient than password authentication: every time you log in to the server, instead of typing a short password, you have to type a longer passphrase. One solution to this is to use an authentication agent, a separate program which holds decrypted private keys and generates signatures on request. WinSCP can use PuTTY's authentication agent, called [[ui_pageant|Pageant]]. When you begin a Windows session, you start Pageant and load your private key into it (typing your passphrase once). For the rest of your session, you can start WinSCP any number of times and Pageant will automatically generate signatures without you having to do anything. When you close your Windows session, Pageant shuts down, without ever having stored your decrypted private key on disk. Many people feel this is a good compromise between security and convenience. This can make public-key authentication less convenient than password authentication: every time you log in to the server, instead of typing a short password, you have to type a longer passphrase. One solution to this is to use an authentication agent, a separate program which holds decrypted private keys and generates signatures on request. WinSCP can use PuTTY's authentication agent, called [[ui_pageant|Pageant]]. When you begin a Windows session, you start Pageant and load your private key into it (typing your passphrase once). For the rest of your session, you can start WinSCP any number of times and Pageant will automatically generate signatures without you having to do anything. When you close your Windows session, Pageant shuts down, without ever having stored your decrypted private key on disk. Many people feel this is a good compromise between security and convenience.
-There is more than one public-key algorithm available. The most common is RSA, but others exist, notably DSA (otherwise known as DSS), the USA's federal Digital Signature Standard. ((&puttydoccite))+There is more than one public-key algorithm available. The most common are RSA and ECDSA, but others exist, notably DSA (otherwise known as DSS), the USA's federal Digital Signature Standard. ((&puttydoccite))
===== [[generate]] Generating Keys ===== ===== [[generate]] Generating Keys =====
To generate a key pair, use the [[ui_puttygen|PuTTYgen]] application. To generate a key pair, use the [[ui_puttygen|PuTTYgen]] application.
 +
 +You can start PuTTYgen directly from [[ui_login_authentication|Authentication page]] of Advanced Site Settings dialog. If you start PuTTYgen this way, WinSCP will automatically pick up the generated key.
===== [[private]] Private Keys ===== ===== [[private]] Private Keys =====
-Different file formats are used to store SSH-1 and SSH-2 private keys. While there is only one commonly used format for SSH-1 keys, there are several formats used for SSH-2 keys. WinSCP supports PuTTY format, as authors of PuTTY [[&url(keyformat)|claim that it is the best one]]. +Different file formats are used to store SSH private keys. WinSCP supports PuTTY format, as authors of PuTTY [[&url(keyformat)|claim that it is the best one]].
-WinSCP also recognizes (but does not accept) the other two formats (OpenSSH and ssh.com), so it can suggest you to convert them. To convert the key file use [[ui_puttygen|PuTTYgen]] application.+WinSCP also recognizes (but does not accept) the other two formats (OpenSSH and ssh.com), and it can convert the keys to PuTTY format for you. To convert the key file you can also use ''[[commandline#keygen|/keygen]]'' command-line switch or [[ui_puttygen|PuTTYgen]] application.

Last modified: by martin