首页 > 其他分享 >Git使用SSH公钥

Git使用SSH公钥

时间:2023-01-19 15:23:31浏览次数:42  
标签:Git rsa gitee 133 公钥 SSH key ssh

生成SSH公钥

你可以按如下命令来生成 ssh key:

ssh-keygen -t rsa -C "itldg"

其中的 itldgssh key 的名称

Generating public/private rsa key pair.
Enter file in which to save the key (C:\Users\Administrator/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in C:\Users\Administrator/.ssh/id_rsa.
Your public key has been saved in C:\Users\Administrator/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:xxxxxxxxxxxxxxxxxxxxxxxx itldg
The key's randomart image is:
+---[RSA 3072]----+
| ..+ .o.E        |
|o  o*. .         |
|o..++   . .      |
| +.+ o   +       |
|o   B   S        |
|+.oo =  .        |
|o++BBo o         |
|. **Boo          |
| +BB.            |
+----[SHA256]-----+

按照提示完成三次回车,即可生成 ssh key。通过查看 ~/.ssh/id_rsa.pub 文件内容,获取到你的 public key

cat ~/.ssh/id_ed25519.pub
ssh-rsa xxxxxxxxxxxxxxxxxxx itldg

添加SSH公钥

在git平台中添加SSH公钥(以gitee为例)

image

验证使用

首次使用需要确认并添加主机到本机SSH可信列表。

ssh -T [email protected]
The authenticity of host 'gitee.com (212.64.63.215)' can't be established.
ECDSA key fingerprint is SHA256:xxxxxxxxxxxxxxx.
Are you sure you want to continue connecting (yes/no/[fingerprint])? 

输入yes,提示successfully 则证明添加成功。

Warning: Permanently added 'gitee.com,212.64.63.215' (ECDSA) to the list of known hosts.
Hi 老大哥! You've successfully authenticated, but GITEE.COM does not provide shell access.

image

拉取测试

image

复制SSH的拉取地址(公开的仓库,可用于测试)

git clone [email protected]:itldg/vscode-ldggist.git

image

Cloning into 'vscode-ldggist'...
remote: Enumerating objects: 133, done.
remote: Counting objects: 100% (133/133), done.
remote: Compressing objects: 100% (130/130), done.
Receiving objects:  90% (120/133), 1.64 MiB | 3.21 MiB/seused 0
Receiving objects: 100% (133/133), 1.85 MiB | 3.49 MiB/s, done.
Resolving deltas: 100% (67/67), done.

至此配置完成,测试成功

标签:Git,rsa,gitee,133,公钥,SSH,key,ssh
From: https://www.cnblogs.com/jianzhan/p/git-ssh.html

相关文章

  • git 关联 github、gitee 仓库
    github官网创建仓库,取得仓库地址,我的这个是  https://github.com/xue-y/pay.git  gitee官网点击创建仓库,右上角 新建导入,进入导入页面 选择语言,点击导入按钮......
  • git_test
    项目的开发是一个不断迭代的过程,开发过程中程序员需要不断的对代码进行编写和更正。这就带来很多的问题。首先,开发中代码会存在多个版本,我们如何将代码在多个版本间进行切......
  • Hugo + Github 静态托管自己博客
    详情hugo:官网地址Go-lang:官网地址Git:官网地址辅助工具->GithubProxy:官网地址......
  • 用Gitbash将整个文件上传到github
    试过很多的方法,但发现就这个适用于我 1.先找到想上传的文件夹,进入该文件夹,右键gitbash-here 2.在gitbash界面输入gitclonehttps://XXXX.git即你要上传的仓库链接......
  • jks获取公钥私钥
    openssl生成私钥genrsa-outrsa_private_key.pem生成公钥rsa-inrsa_private_key.pem-pubout-outrsa_public_key.pem生成JKSkeytool-genkey-aliasjwt-key......
  • git blame All In One
    gitblameAllInOnegit高级教程gitblame$git--help#'githelp-a'and'githelp-g'listavailablesubcommandsandsomeconceptguides.#See'githe......
  • Linux下开启防火墙放行nfs,ssh,httpd,dns,chrony服务(iptables,firewalld),firewalld端口转发
     环境:CentOS7.9什么是防火墙防火墙:防火墙是位于内部网和外部网之间的屏障,它按照系统管理员预先定义好的规则来控制数据包的进出。防火墙又可以分为硬件防火墙与软件......
  • ssh登录异常
    概述golang实现telnet效果发现ssh异常,在正常的linux是没问题在wsl下提示如下异常envwindow11wsl2.0golang异常信息openfailed:administrativelyprohibited:o......
  • GitHub - 电脑无法访问GitHub
    通过下面网址查询最新的IP地址:https://github.com.ipaddress.comhttps://www.ipaddress.com然后配置到host中202103IP地址为:140.82.112.3windows:Windows电脑有时打不......
  • SSH 远程免密登录(公钥登录)
    应用场景避免每次连接开发机都输入密码,在企业中也常常限制密码登录的方式,需要每次走公司的鉴权流程;授权他人登录时,利用ssh公钥授权,不需要把用户名和密码暴露给他人。......