git-ssh 配置和使用

简介:

1、设置Git的user name和email:(如果是第一次的话)

    $ git config --global user.name "humingx"
    $ git config --global user.email "humingx@yeah.net"

2、生成密钥

    $ ssh-keygen -t rsa -C "humingx@yeah.net"

连续3个回车。如果不需要密码的话。
最后得到了两个文件:id_rsaid_rsa.pub


如果不是第一次,就选择overwrite.

3、添加密钥到ssh-agent

确保 ssh-agent 是可用的。ssh-agent是一种控制用来保存公钥身份验证所使用的私钥的程序,其实ssh-agent就是一个密钥管理器,运行ssh-agent以后,使用ssh-add将私钥交给ssh-agent保管,其他程序需要身份验证的时候可以将验证申请交给ssh-agent来完成整个认证过程。

    # start the ssh-agent in the background
    eval "$(ssh-agent -s)"
    Agent pid 59566

添加生成的 SSH key 到 ssh-agent。

    $ ssh-add ~/.ssh/id_rsa

4、登陆Github, 添加 ssh 。

id_rsa.pub文件里的内容复制到这里





5、测试:

    $ ssh -T git@github.com

你将会看到:

    The authenticity of host 'github.com (207.97.227.239)' can't be established.
    RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48. Are you sure you want to continue connecting (yes/no)? 

选择 yes

    Hi humingx! You've successfully authenticated, but GitHub does not provide shell access.

如果看到Hi后面是你的用户名,就说明成功了。

6、修改.git文件夹下config中的url

修改前

    [remote "origin"]
    url = https://github.com/humingx/humingx.github.io.git
    fetch = +refs/heads/*:refs/remotes/origin/* 

修改后

    [remote "origin"]
    url = git@github.com:humingx/humingx.github.io.git
    fetch = +refs/heads/*:refs/remotes/origin/*

7、发布

 




    本文转自 一点点征服   博客园博客,原文链接:http://www.cnblogs.com/ldq2016/p/7418206.html ,如需转载请自行联系原作者


相关文章
|
4天前
|
消息中间件 安全 Unix
SSH配置多台服务器之间的免密登陆以及登陆别名
SSH配置多台服务器之间的免密登陆以及登陆别名
15 1
|
3月前
|
Ubuntu 安全 网络安全
百度搜索:蓝易云【Ubuntu系统SSH服务端配置】
现在,你已经成功在Ubuntu系统上配置了SSH服务端。这将允许其他计算机通过SSH协议连接到你的Ubuntu系统,并进行远程管理和操作。请注意,远程访问有安全风险,建议在生产环境中采取必要的安全措施来保护系统。
37 3
|
2月前
|
安全 Shell 网络安全
【Git】TortoiseGit(小乌龟)配置SSH和使用
【Git】TortoiseGit(小乌龟)配置SSH和使用
130 0
|
7天前
|
Shell 网络安全 开发工具
配置SSH时候,Permission denied问题解决方法
配置SSH时候,Permission denied问题解决方法
23 4
|
1月前
|
开发工具 数据库 数据安全/隐私保护
【Git】—— git的配置
【Git】—— git的配置
【Git】—— git的配置
|
1月前
|
安全 Shell 网络安全
ssh配置无密码验证
ssh配置无密码验证要在SSH中配置无密码验证,您需要使用公钥验证【2月更文挑战第18天】
36 1
|
1月前
|
Shell 网络安全 数据安全/隐私保护
配置多个SSH公钥流程
配置多个SSH公钥流程
|
1月前
|
存储 安全 网络安全
Git 安全远程访问:SSH 密钥对生成、添加和连接步骤解析
SSH(Secure Shell)是一种用于安全远程访问的协议,它提供了加密通信和身份验证机制。在使用 SSH 连接到远程 Git 存储库时,您可以使用 SSH 密钥对来确保安全性。以下是关于如何生成和使用 SSH 密钥对的详细步骤: 生成 SSH 密钥对
98 2
|
2月前
|
网络安全 开发工具 数据安全/隐私保护
[Git]关联远程库的两种方法及配置
本篇文章对gitee公钥配置、同电脑连接多个gitee账号公钥配置等方法进行阐述, 如果文中阐述不全或不对的,多多交流。
67 0
[Git]关联远程库的两种方法及配置
|
2月前
|
网络安全
github或gitee配置ssh
github或gitee配置ssh
21 0