文档章节

git 在mac上使用git clone时每次需要输入密码的解决方案

张宏亮
 张宏亮
发布于 2018/05/13 08:49
字数 482
阅读 32
收藏 1

Generating a new SSH key and adding it to the ssh-agent

After you've checked for existing SSH keys, you can generate a new SSH key to use for authentication, then add it to the ssh-agent.

If you don't already have an SSH key, you must generate a new SSH key. If you're unsure whether you already have an SSH key, check for existing keys.

If you don't want to reenter your passphrase every time you use your SSH key, you can add your key to the SSH agent, which manages your SSH keys and remembers your passphrase.

Generating a new SSH key

  1. Open Terminal.

  2. Paste the text below, substituting in your GitHub email address.

    ssh-keygen -t rsa -b 4096 -C "your_email@example.com"

    This creates a new ssh key, using the provided email as a label.

    Generating public/private rsa key pair.
  3. When you're prompted to "Enter a file in which to save the key," press Enter. This accepts the default file location.

    Enter a file in which to save the key (/Users/you/.ssh/id_rsa): [Press enter]
  4. At the prompt, type a secure passphrase. For more information, see "Working with SSH key passphrases".
    Enter passphrase (empty for no passphrase): [Type a passphrase]
    Enter same passphrase again: [Type passphrase again]

Adding your SSH key to the ssh-agent

Before adding a new SSH key to the ssh-agent to manage your keys, you should have checked for existing SSH keys and generated a new SSH key. When adding your SSH key to the agent, use the default macOS ssh-add command, and not an application installed by macportshomebrew, or some other external source.

  1. Start the ssh-agent in the background.

    eval "$(ssh-agent -s)"
    Agent pid 59566
  2. If you're using macOS Sierra 10.12.2 or later, you will need to modify your ~/.ssh/config file to automatically load keys into the ssh-agent and store passphrases in your keychain.

    Host *
     AddKeysToAgent yes
     UseKeychain yes
     IdentityFile ~/.ssh/id_rsa
    
  3. Add your SSH private key to the ssh-agent and store your passphrase in the keychain. If you created your key with a different name, or if you are adding an existing key that has a different name, replace id_rsa in the command with the name of your private key file.

    ssh-add -K ~/.ssh/id_rsa

    Note: The -K option is Apple's standard version of ssh-add, which stores the passphrase in your keychain for you when you add an ssh key to the ssh-agent.

    If you don't have Apple's standard version installed, you may receive an error. For more information on resolving this error, see "Error: ssh-add: illegal option -- K."

  4. Add the SSH key to your GitHub account.

Further reading

© 著作权归作者所有

张宏亮
粉丝 13
博文 216
码字总数 14765
作品 0
杭州
CTO(技术副总裁)
私信 提问
spring-cloud-config-server之拉取git失败解决方案

最近在搞springcloud-config配置中心,windows中的git出了点小毛病,本地的global配置文件一直处于失效状态,小乌龟拉代码也不行,但是git bash 黑窗口使用git clone命令是可以的,但还是需要...

落叶清风
2018/08/24
140
0
git 每次提交需要输入密码

  亲测可行(第一种)   原文:git每次提交都要输入密码怎么办   ================COPY=========================== 不少用户反映在使用G...

戎码半生
2017/03/06
0
0
Windows下Git命令行基本使用

一、准备工作 (1)在 https://github.com 网站上注册一个账号并设置用户名、密码,新建一个repository (2)在网站 http://msysgit.github.io/ 上下载git,并安装 二、设置SSH 1、首先在本地...

quiet_girl
2017/10/26
0
0
TortoiseGit的安装和使用方法

首先贴出msysGit和TortoiseGit的下载链接:http://pan.baidu.com/s/1CT4eE 安装说明: 一.首先要安装msysGit 1、点击安装程序(如 Git-1.7.9-preview20120201.exe )开始安装。 2、 默认安装...

橙创wdl
2015/01/26
3
0
liunx下git设置用户名和密码(含单独项目)

设置git用户名/邮箱 git config --global user.name [username] git config --global user.email [email] 注:如果是单项目,就在项目文件夹下设置,去掉global; 但是这个仅仅是设置用户名...

percy94
2017/10/27
60
0

没有更多内容

加载失败,请刷新页面

加载更多

会用python把linux命令写一遍的人,进大厂有多容易?

看过这篇《2000字谏言,给那些想学Python的人,建议收藏后细看!》的读者应该都对一个命令有点印象吧?没错,就是 linux 中经常会用到的 ls 命令。 文章中我就提到如何提升自己的 python 能力...

上海小胖
29分钟前
6
0
HashMap的特性

一、hashmap数据结构:哈希表结构:数组+链表 hashmap调用默认构造方法会产生一个默认底层是长度为16的Entry数组,首先调用key的hasCode()方法来得到一个整数, int hash = hash(key.hashCode...

GGbird
30分钟前
16
0
第五章 spring-connet之Imports注解来龙去脉

前言 imports是一个在spring体系里非常重要的注解,基本每个Enable开头的注解必然有一个import注解。接下来我们深入研究下import的作用。看小节的同学建议先取看PostProcessorRegistrationDe...

鸟菜啊
33分钟前
6
0
CentOS部署Harbor镜像仓库

关于Harbor Harbor是用于存储和分发Docker镜像的镜像仓库服务,相比Docker Registry,Harbor在安全、标识、管理等方面做了增强,更适合企业使用; 官方网站:https://goharbor.io/ 官方开源:...

程序员欣宸
38分钟前
7
0
JavaScript调试必会的8个console方法

每个JavaScript开发者都用过console.log()来调试程序,但实际上Console对象还提供了很多其他方法可以提高调试效率。本文将介绍8个有趣的Console方法,即使JavaScript老手也不一定知道! 1、c...

汇智网教程
今天
10
0

没有更多内容

加载失败,请刷新页面

加载更多

返回顶部
顶部