在github中配置ssh

简介:

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

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

2、生成密钥

linux    $ 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来完成整个认证过程。

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

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

linux    $ ssh-add ~/.ssh/id_rsa

4、登陆Github, 添加 ssh 。

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





5、测试:

linux    $ 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、发布

本文转自 Lee_吉  博客,原文链接:   http://blog.51cto.com/12173069/2044296     如需转载请自行联系原作者

相关文章
|
16天前
|
网络协议 Shell 网络安全
ssh: connect to host github.com port 22: Connection refused
本文讨论了在使用Git命令操作GitHub时遇到的"ssh: connect to host github.com port 22: Connection refused"错误,分析了可能的原因,并提供了使用443端口或https协议作为解决方案,最终确定问题是由于DNS解析错误导致,通过修改hosts文件解决。
ssh: connect to host github.com port 22: Connection refused
|
24天前
|
安全 网络协议 Shell
Github代码仓库SSH配置流程
这篇文章是关于如何配置SSH以安全地连接到GitHub代码仓库的详细指南,包括使用一键脚本简化配置过程、生成SSH密钥对、添加密钥到SSH代理、将公钥添加到GitHub账户以及测试SSH连接的步骤。
30 0
Github代码仓库SSH配置流程
|
29天前
|
网络安全 开发工具 git
拉取 gitee 代码,配置SSH,Please make sure you have the correct access rights
拉取 gitee 代码,配置SSH,Please make sure you have the correct access rights
32 1
|
1月前
|
Shell 网络安全 开发工具
Gerrit✨Gerrit服务器简介 与 配置SSH keys
Gerrit✨Gerrit服务器简介 与 配置SSH keys
|
16天前
|
网络安全 Windows
在Windows电脑上启动并配置SSH服务
在Windows电脑上启动并配置SSH服务
38 0
|
20天前
|
Linux C++ Docker
【Azure Developer】在Github Action中使用Azure/functions-container-action@v1配置Function App并成功部署Function Image
【Azure Developer】在Github Action中使用Azure/functions-container-action@v1配置Function App并成功部署Function Image
|
24天前
|
Ubuntu Shell 网络安全
【Ubuntu】配置SSH
【Ubuntu】配置SSH
28 0
|
24天前
|
安全 Linux 网络安全
在Linux中,如何配置SSH以确保远程连接的安全?
在Linux中,如何配置SSH以确保远程连接的安全?
|
30天前
|
安全 Linux Shell
如何在 Linux 服务器上配置基于 SSH 密钥的身份验证
如何在 Linux 服务器上配置基于 SSH 密钥的身份验证
36 0
|
30天前
|
安全 Unix Shell
如何在 FreeBSD 服务器上配置基于 SSH 密钥的身份验证
如何在 FreeBSD 服务器上配置基于 SSH 密钥的身份验证
56 0