git生成ssh公钥_git生成ssh公钥怎么找不到
如何生成SSH key
如何生成SSH key
git生成ssh公钥_git生成ssh公钥怎么找不到
git生成ssh公钥_git生成ssh公钥怎么找不到
SSH key提供了一种与GitHub通信的方式,通过这种方式,能够在不输入密码的情况下,将GitHub作为自己的remote端,进行版本控制
步骤
检查SSH keys是否存在
生成新的ssh key
将ssh key添加到GitHub中
如何生成SSH KEY
1. 检查SSH keys是否存在
输入下面的命令,如果有文件id_rsa.pub 或 id_dsa.pub,则直接进入步骤3将SSH key添加到GitHub中,否则进入第二步生成SSH key
ls -al ~/.ssh
# Lists the files in your .ssh directory, if they exist
2. 生成新的ssh key
步:生成public/private rsa key pair
在命令行中输入ssh-keygen -t rsa -C ""
默认会在相应路径下(/your_home_path)生成id_rsa和id_rsa.pub两个文件,如下面代码所示
ssh-keygen -t rsa -C ""
# Creates a new ssh key using the provided email
Generating public/private rsa key pair.
Enter file in which to se the key (/your_home_path/.ssh/id_rsa):
第二步:输入passphrase(本步骤可以跳过)
设置passphrase后,进行版本控制时,每次与GitHub通信都会要求输入passphrase,以避免某些“失误”
Enter passphrase (empty for no passphrase): [Type a passphrase]
Enter same passphrase again: [Type passphrase again]
sample result:
Your identification has been sed in /your_home_path/.ssh/id_rsa.
Your public key has been sed in /your_home_path/.ssh/id_rsa.pub.
The key fingerprint is:
#01:0f:f4:3b:ca:85:d6:17:a1:7d:f0:68:9d:f0:a2:db 第三步:将新生成的key添加到ssh-agent中:
# start the ssh-agent in the background
eval "$(ssh-agent -s)"
Agent pid 59566
ssh-add ~/.ssh/id_rsa
3. 将ssh key添加到GitHub中
用自己喜欢的文本编辑器打开id_rsa.pub文件,里面的信息即为SSH key,将这些信息到GitHub的Add SSH key页面即可
不同的作系统,均有一些命令,直接将SSH key从文件拷贝到粘贴板中,如下:
mac
pbcopy < ~/.ssh/id_rsa.pub
# Copies the contents of the id_rsa.pub file to your clipboard
windows
clip < ~/.ssh/id_rsa.pub
# Copies the contents of the id_rsa.pub file to your clipboard
linux
sudo apt-get install xclip
# Downloads and installs xclip. If you don't he `apt-get`, you might need to use another installer (like `yum`)
xclip -sel clip < ~/.ssh/id_rsa.pub
# Copies the contents of the id_rsa.pub file to your clipboard
Git是分布式的代码管理工具,远程的代码管理是基于SSH的,所以要使用远程的Git则需要SSH的配置。
如何在在git远程仓库上添加公钥
步
首先在本地创建一个文件夹,git init 创建本地仓库
编写完成后 git add . 提交所有的项目
git commit -m "提交" 注释
然后打开coding创建项目
第二步
生成ssh公钥
-. 设置Git的user name和email:
$ git config --global user.name "xuhaiyan"$ git config --global user.email ""
-. 生成SSH密钥过程:
1.查看是否已经有了ssh密钥:
cd ~/.ssh
如果没有密钥则不会有此文件夹,有则备份删除
2.生存密钥:
$ ssh-keygen -t rsa -C “”
按3个回车,密码为空。
得到了两个文件:id_rsa和id_rsa.pub
之后打开id_rsa.pub文件将公钥进入 : coding-账户-SSH公钥,添加进去即可
第三步
选择项目-代码:
git remote add origin git@xxx/xxx //ssh地址
git push -u origin
git ssh key 生成在哪
1、首先你要安装Git工具 2、右键鼠标,选中 “Git Bash here”,当然你也可以在windows的 “开始”--->“所以程序”,或者安装目录打开它 3、输入指令,进入.ssh文件夹 cd ~/.ssh/ 如果提示 “ No such file or directory”,你可以手动的创建一个 .ssh...
简单的 Mac配置gitlab ssh密钥方法
之前尝试过按照网上的方法配置密钥,虽然配置成功了但是每次进行任何作还是得输入密码(不用输账号,只是输入 .rsa.pub的passphrase),还是很不方便,自己重新配置了下,尝试了一下,不用输密码了。
在有了gitlab账号后:
1.在终端(根目录就行)输入 ssh-keygen -t rsa -C + gitlab上的email。
2.回车之后会让你输入存储id_rsa和id_rsa.pub的目录,不用管直接继续回车即可
3.回车之后会出现让输入密码, 关键的来了,这个密码,不要输入任何东西,直接回车(不然每次进行git和远程仓库有关系的作的时候都得输入这个密码)。 这两步直接enter之后密钥对就创建成功了
4.接下来去电脑桌面 左上角的前往-前往文件夹
5.点开之后直接在输入框里输入 ~/.ssh 然后回车,就会出现id_rsa和id_rsa.pub两个文件。右键打用文本编辑打开id_rsa.pub,将里面的东西全部
6.打开gitlab,点击右上角红框位置打开settings
7.进入settings后,点击左侧SSH Keys
8.把刚才的id_rsa.pub里的东西粘贴到1所指的框框里,( title可以随便写,也可以什么都不写)然后点击2指的 Add key
现在就大功告成了,可以不输密码的进行git pull 、push、clone等作了。
换电脑之后生成git ssh密钥(mac版)
1.先安装Xcode,安装完后命令行输入git,测试git环境是否安装,如果显示没有文件夹则没有环境
如果显示下图,则表示git安装好
2.运行cat ~/.ssh/id_rsa.pub,查看是否有ssh的文件。有文件直接就行
3.运行ssh-keygen,(会要求输入新的文件夹名称和密码,可以不理会一直回车)生成新的密钥,然后再运行cat ~/.ssh/id_rsa.pub,将'ssh-rsa'那段全部(包括‘ssh-rsa’),粘贴到github的ssh密钥处(点击头像-->setting-->ssh key)即可
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系 836084111@qq.com 删除。