会哭的雨 2019-11-09
https://gitee.com/help/articles/4181#article-header0
ssh-keygen -t rsa -C ""
在本地生成 rsa 公私钥。直接回车。名称必须是默认的id_rsa
。
将公钥保存到码云
ssh -T
测试连接生成 known_hosts
文件,测试连接的时候要输入 yes
不能直接回车
MINGW64 /e/mozq/00store/01 $ ssh-keygen -t rsa -C "" Generating public/private rsa key pair. Enter file in which to save the key (/c/Users/1/.ssh/id_rsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /c/Users/1/.ssh/id_rsa. Your public key has been saved in /c/Users/1/.ssh/id_rsa.pub. The key fingerprint is: SHA256:3n4Ctfa9e59mAKmFxxY+4z+3i7Y73vrB46iAO9wL5q0 The key's randomart image is: +---[RSA 3072]----+ | | | . | | + o | | | | S.*.+ | | .ooo. .. | | .+o+.....+ | | oo+oo o=*+=| | Eooo++B&@=| +----[SHA256]-----+
设置 > 安全设置 > SSH公钥
MINGW64 /e/mozq/00store/01 $ ssh -T The authenticity of host 'gitee.com (212.64.62.174)' can't be established. ECDSA key fingerprint is SHA256:FQGC9Kn/eye1W8icdBgrQp+KkGYoFgbVr17bmjey0Wc. Are you sure you want to continue connecting (yes/no/[fingerprint])? yes Warning: Permanently added 'gitee.com,212.64.62.174' (ECDSA) to the list of known hosts. Hi 魔有追求! You've successfully authenticated, but GITEE.COM does not provide shell access.
私钥名称必须为默认的id_rsa
,并且放在用户目录的.ssh文件夹下。
C:\Users\1\.ssh>tree /f 卷 Windows 的文件夹 PATH 列表 卷序列号为 AE9A-3125 C:. │ id_rsa │ id_rsa.pub │ known_hosts
同时连接多个库,这些库默认都是读取id_rsa文件,可以建立文件夹,用哪个库把哪个库的rsa文件粘贴出来。比如我要用学成的公私钥,我就把他粘贴出来放到 .ssh
文件夹中。
C:\Users\1\.ssh>tree /f 卷 Windows 的文件夹 PATH 列表 卷序列号为 AE9A-3125 C:. │ id_rsa │ id_rsa.pub │ known_hosts │ ├─sand │ id_rsa │ id_rsa.pub │ known_hosts │ ├─store_sand │ id_rsa │ id_rsa.pub │ known_hosts │ └─xc id_rsa id_rsa.pub known_hosts
# 生成的私钥名称必须为id_rsa,也就是默认的名称,不然的话也会找不到。 C:\Users\1\.ssh>tree /f 卷 Windows 的文件夹 PATH 列表 卷序列号为 AE9A-3125 C:. │ id_rsa │ id_rsa.pub │ known_hosts
# 连接测试时如果直接回车,不输入yes,则会显示被拒绝。输入yes则会连接成功。 MINGW64 /e/mozq/00store/01 $ ssh -T The authenticity of host 'gitee.com (212.64.62.174)' can't be established. ECDSA key fingerprint is SHA256:FQGC9Kn/eye1W8icdBgrQp+KkGYoFgbVr17bmjey0Wc. Are you sure you want to continue connecting (yes/no/[fingerprint])? Host key verification failed. # 连接测试时如果直接回车,输入yes连接成功。 MINGW64 /e/mozq/00store/01 $ ssh -T The authenticity of host 'gitee.com (212.64.62.174)' can't be established. ECDSA key fingerprint is SHA256:FQGC9Kn/eye1W8icdBgrQp+KkGYoFgbVr17bmjey0Wc. Are you sure you want to continue connecting (yes/no/[fingerprint])? yes Warning: Permanently added 'gitee.com,212.64.62.174' (ECDSA) to the list of known hosts. Hi 魔有追求! You've successfully authenticated, but GITEE.COM does not provide shell access.