SSH in GitBash & TortoiseGit

SSH in Git Bash & Tortoise Git

有的同学使用Git生成了SSH密钥发现无法使用TortoiseGit进行SSH协议的连接,这里面其实有点不太一样。

SSH in Git Bash

1.Generate SSH Key

Two ways.

  1. Use command line in GitBash

    • 在任意窗口右键打开GitBash
    • 输入命令行生成SSH密钥
    ssh-keygen -t rsa -C "your email" -b 4096
    
  2. Use Git GUI

    • 在任意窗口右键打开Git GUI
    • Click Help -> Generate SSH Key or Show SSH Key

Where are keys?

# 百分号内容表示你的用户文件夹
%User Directory%/.ssh/

In this directory, you can see at least two files:

  • id_rsa: private SSH key
  • id_rsa.pub: public SSH key, you need to add this to your GitHub/GitLab

2.Using SSH in Git Bash/GUI

  1. 将上一步的id_rsa.pub文件中的内容配置到你GitHub/GitLab

  1. 在本地使用Git Bash, 这里我给了简单的例子

    • 克隆远程仓库到本地(SSH协议)

      git clone [git@开头的ssh链接]
      
    • 进入本地仓库项目, 此时的目录都可叫做工作空间(working directory)

      cd [Project Name]
      
    • [可选]创建一个文件

      touch README.md
      
    • 将文件添加到暂存区(staging area)

      git add README.md
      
    • 将暂存区文件提交到本地仓库(local repository)

      git commit -m "这里是注释,必填"
      
    • 将本地仓库的变更提交到远程仓库(remote repository)

      git push -u origin master
      

SSH in Tortoise Git

You need to install the Tortoise first.

Reference

1.Generate SSH Key

Find PuTTYgen Client in your system, it has been installed with Tortoise Git.

  • System Start -> Search “Puttygen” -> Click to Run

Then, Click Generate, wait for a moment.

  • You can set your E-mail in Key comment
  • You can set password in Key passphrase

After generated, save public key & private key.

2.Using SSH in Tortoise Git

  1. 将上一步生成的公钥配置到你GitHub/GitLab中,可参考前文。
  2. 使用实例,这里以Clone一个Git仓库为例
    • 右键打开Git Clone…
    • 键入Git链接
    • 勾选Load Putty Key, 选择前面生成的私钥
    • OK


3. Tortoise Git图形化界面的具体使用就不举例了


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值