lan@DESKTOP-8ISAT6B MINGW64 /e/Blog $ ssh-keygen -t rsa -C xxxxxxxxxxx@qq.com Generating public/private rsa key pair. Enter file in which to save the key (/c/Users/lan/.ssh/id_rsa): id_rsa_lanlan233 Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in id_rsa_lanlan233. Your public key has been saved in id_rsa_lanlan233.pub. The key fingerprint is: SHA256:sFQcPwt2pzC2kzkclvjA5TCklu60+YdTh/QhlKFMQZ8 1819091040@qq.com The key's randomart image is: +---[RSA 2048]----+ | oBo=+ | | * X++ | | + O.E + . | | o . XoX.= | | o ..S+o. | | o o ooo | | + o . | | .o . | | .o | +----[SHA256]-----+ lan@DESKTOP-8ISAT6B MINGW64 /e/Blog
默认SSH只会读取id_rsa,所以为了让SSH识别新的私钥,需要将其添加到SSH agent 使用命令:ssh-add ~/.ssh/id_rsa_lanlan233 如果报错:Could not open a connection to your authentication agent.无法连接到ssh agent 可执行ssh-agent bash命令后再执行ssh-add ~/.ssh/id_rsa_lanlan233命令。
1 2 3 4 5 6 7 8 9 10 11 12
lan@DESKTOP-8ISAT6B MINGW64 ~/.ssh $ ls id_rsa id_rsa.pub id_rsa_lanlan233 id_rsa_lanlan233.pub known_hosts lan@DESKTOP-8ISAT6B MINGW64 ~/.ssh $ ssh-add id_rsa_lanlan233 Could not open a connection to your authentication agent. lan@DESKTOP-8ISAT6B MINGW64 ~/.ssh $ ssh-agent bash lan@DESKTOP-8ISAT6B MINGW64 ~/.ssh $ ssh-add id_rsa_lanlan233 Identity added: id_rsa_lanlan233 (id_rsa_lanlan233)