好久没有用git了,今天突然执行了一下

$git submodule update --init --recursive

===============================

结果出现如下提示

Cloning into 'Submodules/********'...

Permission denied (publickey).

===============================

由于确实好长时间没有摸过git了,一点印象都没有了。没办法,只能google了,还好一搜就得到一片经典官方帮助:

https://help.github.com/articles/generating-ssh-keys/

=================================

Generating SSH keys

SSH keys are a way to identify trusted computers, without involving passwords. The steps below will walk you through generating an SSH key and adding the public key to your GitHub account.

We recommend that you regularly review your SSH keys list and revoke any that haven't been used in a while.

Tip: GitHub has a Mac client! You can use it without ever touching the command line.

Step 1: Check for SSH keys

First, we need to check for existing SSH keys on your computer. Open Terminal and enter:

ls -al ~/.ssh
# Lists the files in your .ssh directory, if they exist

Check the directory listing to see if you already have a public SSH key. By default, the filenames of the public keys are one of the following:

  • id_dsa.pub
  • id_ecdsa.pub
  • id_ed25519.pub
  • id_rsa.pub

Tip: If you receive an error that the ~/.ssh doesn't exist,, don't worry! We'll create it in Step 2.

Step 2: Generate a new SSH key

  1. With Terminal still open, copy and paste the text below. Make sure you substitute in your GitHub email address.

    ssh-keygen -t rsa -C "your_email@example.com"
    # Creates a new ssh key, using the provided email as a label
    # Generating public/private rsa key pair.
  2. We strongly suggest keeping the default settings as they are, so when you're prompted to "Enter a file in which to save the key", just press Enter to continue.

    # Enter file in which to save the key (/Users/you/.ssh/id_rsa): [Press enter]
    
  3. You'll be asked to enter a passphrase.

    # Enter passphrase (empty for no passphrase): [Type a passphrase]
    # Enter same passphrase again: [Type passphrase again]

    Tip: We strongly recommend a very good, secure passphrase. For more information, see "Working with SSH key passphrases".

  4. After you enter a passphrase, you'll be given the fingerprint, or id, of your SSH key. It will look something like this:

    # Your identification has been saved in /Users/you/.ssh/id_rsa.
    # Your public key has been saved in /Users/you/.ssh/id_rsa.pub.
    # The key fingerprint is:
    # 01:0f:f4:3b:ca:85:d6:17:a1:7d:f0:68:9d:f0:a2:db your_email@example.com

Step 3: Add your key to the ssh-agent

To configure the ssh-agent program to use the SSH key you've generated:

  1. Ensure ssh-agent is enabled:

    # start the ssh-agent in the background
    eval "$(ssh-agent -s)"
    # Agent pid 59566
  2. Add your generated SSH key to the ssh-agent:

    ssh-add ~/.ssh/id_rsa
    

Step 4: Add your SSH key to your account

To configure your GitHub account to use your SSH key:

Copy the SSH key to your clipboard. Keep in mind that your key may also be named id_dsa.pub,id_ecdsa.pub or id_ed25519.pub, in which case you must change the filename as follows:

pbcopy < ~/.ssh/id_rsa.pub
# Copies the contents of the id_rsa.pub file to your clipboard

Warning: It's important to copy the key exactly without adding newlines or whitespace.

Add the copied key to GitHub:

  1. In the top right corner of any page, click .

  2. In the user settings sidebar, click SSH keys.

  3. Click Add SSH key.

  4. In the Title field, add a descriptive label for the new key. For example, if you're using a personal Mac, you might call this key "Personal MacBook Air".
  5. Paste your key into the "Key" field.
  6. Click Add key.
  7. Confirm the action by entering your GitHub password.

Step 5: Test the connection

To make sure everything is working, you'll now try to SSH into . When you do this, you will be asked to authenticate this action using your password, which is the SSH key passphrase you created earlier.

  1. Open Terminal and enter:

    ssh -T git@github.com
    # Attempts to ssh to GitHub
  2. You may see this warning:

    # 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)?

    Verify the fingerprint in the message you see matches the following message, then type yes:

    # Hi username! You've successfully authenticated, but GitHub does not
    # provide shell access.
  3. If the username in the message is yours, you've successfully set up your SSH key!

    If you receive a message about "access denied," you can read these instructions for diagnosing the issue.

    If you're switching from HTTPS to SSH, you'll now need to update your remote repository URLs. For more information, see Changing a remote's URL.

================================

讲的十分详细,再次感谢一下,一步一步安装文档所说进行,竟然意外的发现以前就在自己的github上已经做过类似的操作了。难道真是上了岁数,忘得一干二净......

【ASK】git使用中出现Permission denied (publickey).的更多相关文章

  1. git@github.com: Permission denied (publickey).////remote: Permission to xxx/test.git denied to xxx.等权限问题

    Error msg git@github.com: Permission denied (publickey) 或者: remote: Permission to xxx/test.git denie ...

  2. github:当你想要使用VSCODE开心提交代码时,出现Git:git@github.com:Permission denied(publickey)解决方案

    当你想要使用VSCODE开心提交代码时,出现Git:git@github.com:Permission denied(publickey)弹框 图片: 原因:电脑公钥(publickey)未添加至gi ...

  3. 使用Git出现以下错误"Git@github.com: Permission denied (publickey). Could not read from remote repository."解决方案

    转载于:https://blog.csdn.net/dotphoenix/article/details/100130424 git@github.com: Permission denied (pu ...

  4. git实战中遇到git@github.com: Permission denied (publickey).的问题

    一.问题我们在使用git的时候会建立一个私钥和一个公钥来完成彼此的通讯,因此如何使用给一个指令建立一个秘钥至关重要.但是我在实践的过程中出现了git@github.com: Permission de ...

  5. ubuntu下git clone 出现Permission denied (publickey).

    今天在ubuntu上使用git 克隆 github上面的库,一直权限拒绝Permission denied (publickey). 公钥绑了好几次,都不行: 最后怀疑是git配置公钥地址有问题:打开 ...

  6. centos: git clone提示Permission denied publickey 问题

    问题: Initialized empty Git repository in /data1/mouxuan/fastsocket-private/.git/ Permission denied (p ...

  7. 【git基础】Permission denied (publickey). fatal: Could not read from remote repository

    运行以下git命令的时候出现错误 git push -u origin master error The authenticity of host 'github.com (13.250.177.22 ...

  8. IDEA中使用git报错Permission denied (publickey)

    最近在使用idea开发时,使用git拉取远程仓库的代码时,报错Permission denied (publickey),原因是因为ssh的密钥失效,必须得重新设置下ssh的密钥即可. 命令很简单,在 ...

  9. git 时 出现 Permission denied (publickey).

    https://blog.csdn.net/awp0011/article/details/73368481 第一次使用github.com在本地 执行 git clone git@github.co ...

随机推荐

  1. Yahoo关于性能优化的N条军规

    一. Yahoo的军规条例: 谨记:80%-90%的终端响应时间是花费在下载页面中的图片,样式表,脚本,flash等:详细的解释来这里查:http://developer.yahoo.com/perf ...

  2. Android开发之应用程序更新实现

    近期给项目app做升级.对Android应用程序更新稍有研究,分享一下我的心得. 既然是更新,那么一定是要联网和下载的.所以联网和存储訪问权限时一定要有的: <!-- 权限申请 -->   ...

  3. win10改win7如何设置bios教程

    情况一: 我们按del键(百度自己电脑.主板如何进入bios)进入主板bios后,我们通过键盘将选项移动到 Authentication 菜单(bios界面各不相同,可能不在此项,找到对应 secur ...

  4. CentOS安装rz\sz命令

    执行以下命令进行安装: yum install lrzsz 安装完成后即可操作rz和sz命令. rz:本地文件上传. sz:Linux系统文件下载到本地.

  5. 实验c语言不同类型的指针互用(不推荐只是学习用)

    #include <stdio.h> int main(int argc, char *argv[]) { printf("Hello, world\n"); ]; i ...

  6. PHP时间戳和日期相互转换(文字有问题)

    在php中我们要把时间戳转换日期可以直接使用date函数来实现,如果要把日期转换成时间戳可以使用strtotime()函数实现,下面我来给大家举例说明. 1.php中时间转换函数 strtotime ...

  7. self.navigationItem.titleView 不居中显示的问题

    自定义一个AUIView, AUIView * v=[AUIView new]; self.navigationItem.titleView = v; 在AUIView类内重写 setFrame -  ...

  8. Android4.4的init进程

    1背景 前些日子需要在科室内做关于Android系统启动流程的培训.为此,我在几年前的技术手记的基础上,重新改了一份培训文档.在重新整理文档期间,我也重读了一下Android 4.4的相关代码,发现还 ...

  9. java中的Closeable接口

    一.概述 该接口位于java.io包下,声明例如以下:public interface Closeable Closeable 是能够关闭的数据源或目标. 调用 close 方法可释放对象保存的资源( ...

  10. superobject 序列数据集

    unit uDBJson; interface {$HINTS OFF} uses SysUtils, Classes, Variants, DB, DBClient, SuperObject; ty ...