在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     如需转载请自行联系原作者

相关文章
|
1月前
|
Devops Shell 网络安全
git使用之如何将一套代码同时推送至github|gitee|gitcode|gitlab等多个仓库-含添加ssh-优雅草央千澈完美解决-提供整体提交代码
git使用之如何将一套代码同时推送至github|gitee|gitcode|gitlab等多个仓库-含添加ssh-优雅草央千澈完美解决-提供整体提交代码
94 16
git使用之如何将一套代码同时推送至github|gitee|gitcode|gitlab等多个仓库-含添加ssh-优雅草央千澈完美解决-提供整体提交代码
|
3月前
|
Linux 网络安全 开发工具
IDEA如何配置git和github
【11月更文挑战第14天】本指南详细介绍了如何在 IntelliJ IDEA 中配置 Git 和 GitHub,包括检查和设置 Git 路径、测试配置,以及通过 SSH 或 HTTPS 方式配置 GitHub 仓库的具体步骤。完成配置后,用户可在 IDEA 中轻松进行版本控制操作。
531 0
|
4月前
|
JavaScript Linux Windows
Typora图床配置(用自带的 PicGo-Core(command line) 插件GitHub
Typora图床配置(用自带的 PicGo-Core(command line) 插件GitHub
|
6月前
|
网络协议 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
|
6月前
|
监控 安全 Ubuntu
在Linux中,如何进行SSH服务配置?
在Linux中,如何进行SSH服务配置?
|
6月前
|
安全 网络协议 Shell
Github代码仓库SSH配置流程
这篇文章是关于如何配置SSH以安全地连接到GitHub代码仓库的详细指南,包括使用一键脚本简化配置过程、生成SSH密钥对、添加密钥到SSH代理、将公钥添加到GitHub账户以及测试SSH连接的步骤。
154 0
Github代码仓库SSH配置流程
|
6月前
|
网络安全 开发工具 git
拉取 gitee 代码,配置SSH,Please make sure you have the correct access rights
拉取 gitee 代码,配置SSH,Please make sure you have the correct access rights
97 1
|
6月前
|
网络安全 Windows
在Windows电脑上启动并配置SSH服务
在Windows电脑上启动并配置SSH服务
1540 0
|
6月前
|
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
|
6月前
|
Ubuntu Shell 网络安全
【Ubuntu】配置SSH
【Ubuntu】配置SSH
156 0

热门文章

最新文章