📄 pubkey.but
字号:
the computer the key will be used on, such as \c{simon@simons-pc}.To alter the key comment, just type your comment text into the\q{Key comment} box before saving the private key. If you want tochange the comment later, you can load the private key back intoPuTTYgen, change the comment, and save it again.\S{puttygen-passphrase} Setting a passphrase for your key\cfg{winhelp-topic}{puttygen.passphrase}The \q{Key passphrase} and \q{Confirm passphrase} boxes allow you tochoose a passphrase for your key. The passphrase will be used toencrypt the key on disk, so you will not be able to use the keywithout first entering the passphrase.When you save the key, PuTTY will check that the \q{Key passphrase}and \q{Confirm passphrase} boxes both contain exactly the samepassphrase, and will refuse to save the key otherwise.If you leave the passphrase fields blank, the key will be savedunencrypted. You should \e{not} do this without good reason; if youdo, your private key file on disk will be all an attacker needs togain access to any machine configured to accept that key. If youwant to be able to log in without having to type a passphrase everytime, you should consider using Pageant (\k{pageant}) so that yourdecrypted key is only held in memory rather than on disk.Under special circumstances you may genuinely \e{need} to use a keywith no passphrase; for example, if you need to run an automatedbatch script that needs to make an SSH connection, you can't bethere to type the passphrase. In this case we recommend you generatea special key for each specific batch script (or whatever) thatneeds one, and on the server side you should arrange that each keyis \e{restricted} so that it can only be used for that specificpurpose. The documentation for your SSH server should explain how todo this (it will probably vary between servers).Choosing a good passphrase is difficult. Just as you shouldn't use adictionary word as a password because it's easy for an attacker torun through a whole dictionary, you should not use a song lyric,quotation or other well-known sentence as a passphrase. DiceWare(\W{http://www.diceware.com/}\cw{www.diceware.com}) recommends usingat least five words each generated randomly by rolling five dice,which gives over 2^64 possible passphrases and is probably not a badscheme. If you want your passphrase to make grammatical sense, thiscuts down the possibilities a lot and you should use a longer one asa result.\e{Do not forget your passphrase}. There is no way to recover it.\S{puttygen-savepriv} Saving your private key to a disk file\cfg{winhelp-topic}{puttygen.savepriv}Once you have generated a key, set a comment field and set apassphrase, you are ready to save your private key to disk.Press the \q{Save private key} button. PuTTYgen will put up a dialogbox asking you where to save the file. Select a directory, type in afile name, and press \q{Save}.This file is in PuTTY's native format (\c{*.PPK}); it is the one youwill need to tell PuTTY to use for authentication (see\k{config-ssh-privkey}) or tell Pageant to load (see\k{pageant-mainwin-addkey}).\S{puttygen-savepub} Saving your public key to a disk file\cfg{winhelp-topic}{puttygen.savepub}The SSH 2 protocol drafts specify a standard format for storingpublic keys on disk. Some SSH servers (such as \cw{ssh.com}'s)require a public key in this format in order to acceptauthentication with the corresponding private key. (Others, such asOpenSSH, use a different format; see \k{puttygen-pastekey}.)To save your public key in the SSH 2 standard format, press the\q{Save public key} button in PuTTYgen. PuTTYgen will put up adialog box asking you where to save the file. Select a directory,type in a file name, and press \q{Save}.You will then probably want to copy the public key file to your SSHserver machine. See \k{pubkey-gettingready} for general instructionson configuring public-key authentication once you have generated akey.If you use this option with an SSH 1 key, the file PuTTYgen saveswill contain exactly the same text that appears in the \q{Public keyfor pasting} box. This is the only existing standard for SSH 1public keys.\S{puttygen-pastekey} \q{Public key for pasting into authorized_keysfile}\cfg{winhelp-topic}{puttygen.pastekey}All SSH 1 servers require your public key to be given to it in aone-line format before it will accept authentication with yourprivate key. The OpenSSH server also requires this for SSH 2.The \q{Public key for pasting into authorized_keys file} gives thepublic-key data in the correct one-line format. Typically you willwant to select the entire contents of the box using the mouse, pressCtrl+C to copy it to the clipboard, and then paste the data into aPuTTY session which is already connected to the server.See \k{pubkey-gettingready} for general instructions on configuringpublic-key authentication once you have generated a key.\S{puttygen-load} Reloading a private key\cfg{winhelp-topic}{puttygen.load}PuTTYgen allows you to load an existing private key file intomemory. If you do this, you can then change the passphrase andcomment before saving it again; you can also make extra copies ofthe public key.To load an existing key, press the \q{Load} button. PuTTYgen willput up a dialog box where you can browse around the file system andfind your key file. Once you select the file, PuTTYgen will ask youfor a passphrase (if necessary) and will then display the keydetails in the same way as if it had just generated the key.If you use the Load command to load a foreign key format, it willwork, but you will see a message box warning you that the key youhave loaded is not a PuTTY native key. See \k{puttygen-conversions}for information about importing foreign key formats.\S{puttygen-conversions} Dealing with private keys in other formats\cfg{winhelp-topic}{puttygen.conversions}Most SSH1 clients use a standard format for storing private keys ondisk. PuTTY uses this format as well; so if you have generated anSSH1 private key using OpenSSH or \cw{ssh.com}'s client, you can useit with PuTTY, and vice versa.However, SSH2 private keys have no standard format. OpenSSH and\cw{ssh.com} have different formats, and PuTTY's is different again.So a key generated with one client cannot immediately be used withanother.Using the \q{Import} command from the \q{Conversions} menu, PuTTYgencan load SSH2 private keys in OpenSSH's format and \cw{ssh.com}'sformat. Once you have loaded one of these key types, you can thensave it back out as a PuTTY-format key (\c{*.PPK}) so that you can useit with the PuTTY suite. The passphrase will be unchanged by thisprocess (unless you deliberately change it). You may want to changethe key comment before you save the key, since OpenSSH's SSH2 keyformat contains no space for a comment and \cw{ssh.com}'s defaultcomment format is long and verbose.PuTTYgen can also export private keys in OpenSSH format and in\cw{ssh.com} format. To do so, select one of the \q{Export} optionsfrom the \q{Conversions} menu. Exporting a key works exactly likesaving it (see \k{puttygen-savepriv}) - you need to have typed yourpassphrase in beforehand, and you will be warned if you are about tosave a key without a passphrase.Note that since only SSH2 keys come in different formats, the exportoptions are not available if you have generated an SSH1 key.\H{pubkey-gettingready} Getting ready for public key authenticationConnect to your SSH server using PuTTY with the SSH protocol. When theconnection succeeds you will be prompted for your user name andpassword to login. Once logged in, you must configure the server toaccept your public key for authentication:\b If your server is using the SSH 1 protocol, you should changeinto the \c{.ssh} directory and open the file \c{authorized_keys}with your favourite editor. (You may have to create this file ifthis is the first key you have put in it). Then switch to thePuTTYgen window, select all of the text in the \q{Public key forpasting into authorized_keys file} box (see \k{puttygen-pastekey}),and copy it to the clipboard (\c{Ctrl+C}). Then, switch back to thePuTTY window and insert the data into the open file, making sure itends up all on one line. Save the file.\b If your server is OpenSSH and is using the SSH 2 protocol, youshould follow the same instructions, except that in earlier versionsof OpenSSH 2 the file might be called \c{authorized_keys2}. (Inmodern versions the same \c{authorized_keys} file is used for bothSSH 1 and SSH 2 keys.)\b If your server is \cw{ssh.com}'s SSH 2 product, you need to savea \e{public} key file from PuTTYgen (see \k{puttygen-savepub}), andcopy that into the \c{.ssh2} directory on the server. Then youshould go into that \c{.ssh2} directory, and edit (or create) a filecalled \c{authorization}. In this file you should put a line like\c{Key mykey.pub}, with \c{mykey.pub} replaced by the name of yourkey file.\b For other SSH server software, you should refer to the manual forthat server.You may also need to ensure that your home directory, your \c{.ssh}directory, and any other files involved (such as\c{authorized_keys}, \c{authorized_keys2} or \c{authorization}) arenot group-writable or world-writable. You can typically do this byusing a command such as\c chmod go-w $HOME $HOME/.ssh $HOME/.ssh/authorized_keysYour server should now be configured to accept authentication usingyour private key. Now you need to configure PuTTY to \e{attempt}authentication using your private key. You can do this in any ofthree ways:\b Select the private key in PuTTY's configuration. See\k{config-ssh-privkey} for details.\b Specify the key file on the command line with the \c{-i} option.See \k{using-cmdline-identity} for details.\b Load the private key into Pageant (see \k{pageant}). In this casePuTTY will automatically try to use it for authentication if it can.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -