Mac环境下如何生成ssh密钥?
时间:2023-08-18 01:50:20
git是分布式的代码管理工具,远程的代码管理是基于ssh的,所以要使用远程的git则需要ssh的配置。那么如何在苹果电脑上生成SSH密钥呢?MacOS教程:Mac运行环境如何生成ssh密钥具体教程如下:
以前一直用http协议去拉取代码,可是最近的网络实在很慢,后来发现ssh请求的速度竟然比http要快很多,于是就研究了一下ssh密钥的生成及使用
git安装
这个网上有很多教程就不赘述了.
测试
输入以下命令 git version
返回版本号就表示成功 如 git version 2.20.1 (Apple Git-117)
检测本地是否有ssh
cd ~/.ssh 此命令可以进入到.ssh文件目录下
ls 此命令显示目录下的所有文件
生成ssh密钥
ssh-keygen -t rsa -C "emAIl@xxx.com"
生成成功会提示以下代码
Generating public/private rsa key pAIr.
Enter file in which to save the key (/Users/xxx/.ssh/id_rsa):
之后会提示你保存.ssh/id_rsa文件路径,直接enter即可
Created directory ‘/Users/xxx/.ssh’.
Enter passphrase (empty for no passphrase):
然后会提示你输入密码,两次.因为输入密码以后进行操作的时候都需要输入密码,所以最好不输入,直接enter,成功之后会显示
Your identification has been saved in /Users/xxx/.ssh/id_rsa.
Your public key has been saved in /Users/xxx/.ssh/id_rsa.pub.
The key fingerprint is:
16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48 emAIl@xxx.com
The key’s randomart image is:(后面图形省略)
下一步是添加ssh,输入以下命令
ssh-add ~/.ssh/id_rsa
此时会要求输入密码,之前输入了密码,此时就再次输入,没输入就enter
成功之后终端会显示以下命令
Identity added: /Users/xxx/.ssh/id_rsa (/Users/xxx/.ssh/id_rsa)
最后会在.ssh文件夹下生成两个文件,一个是id_rsa,另一个是id_rsa.push到这一步,ssh已经生成成功,后续操作就需要找到对应的远程代码仓库网站,在setting页面找到ssh密钥选项,一般都会有new ssh密钥的操作,里面有两个选项
1.title 这是区分多个ssh的标题,可以按照你喜欢的方式填写
2.key
key的查看方式如下
vim ~/.ssh/id_rsa.pub
复制显示的所有内容,贴到key里面,这样ssh key就添加到了对应网站里面检测可用性,以github为例,输入命令
ssh git@github.com
显示如下
Hi your_name! You’ve successfully authenticated, but GitHub does not provide shell access.
Connection to github.com closed.
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
在wps文字中怎么插入箭头
WPS word里如何快速对齐文案
![](https://img.aspxhome.com/file/2023/9/a186419_0s.jpg)
wps表格怎么去掉智能表格样式
![](https://img.aspxhome.com/file/2023/1/a171091_0s.png)
GIF动画教程:Excel高亮显示最大值或最小值
![](https://img.aspxhome.com/file/2023/3/a143173_0s.gif)
excel怎样通过出生日期计算年龄
电脑WPS文档如何压缩图片
![](https://img.aspxhome.com/file/2023/9/a184069_0s.png)
三八妇女节到了 如何用PPT动画来表达爱意
![](https://img.aspxhome.com/file/2023/9/a186999_0s.jpg)
升级win10正式版后怎么激活office2013?(已升级和未升级win10通用)
![](https://img.aspxhome.com/file/2023/3/15503_0s.jpg)
shs文件用什么打开
![](https://img.aspxhome.com/file/2023/8/34198_0s.png)
如何开启Apple ID 的两步认证
如何使用“Apple 诊断”来测试您的Mac 是不是存在硬件问题?
![](https://img.aspxhome.com/file/2023/1/a208091_0s.png)
Word2013中升级或降级SmartArt形状
![](https://img.aspxhome.com/file/2023/2/20882_0s.jpg)
怎么保护WPS表格的公式
wps怎么背景音乐?
![](https://img.aspxhome.com/file/2023/2/a168262_0s.gif)
在word文档中如何调整行距呢?
![](https://img.aspxhome.com/file/2023/6/24286_0s.jpg)
怎么用Excel中的定位功能
![](https://img.aspxhome.com/file/2023/5/a167405_0s.png)
如何转换和共享Office 2019文件
![](https://img.aspxhome.com/file/2023/6/22966_0s.jpg)
一招搞定统一excel透视表的值汇总方式
![](https://img.aspxhome.com/file/2023/6/a156886_0s.jpg)
wps Office怎么设页面方向为横向
![](https://img.aspxhome.com/file/2023/4/a168324_0s.jpg)
macOS 10.16将被称为:Mammoth、Skyline或其他
![](https://img.aspxhome.com/file/2023/3/a210083_0s.jpeg)