Github Gitlab SSH 密钥配置

1. 操作流程

  1. 生成密钥(非对称加密)
ssh-keygen -t rsa -C "your_email@example.com"

注意,这里的 -C 表示注释,没有什么用,主要是标记密钥避免自己遗忘。

  1. 查看密钥(公钥)
//进入所属目录
cd ~/.ssh
cat id_rsa.pub

windows 系统在 C:\Users\用户名\.ssh
3. 将公钥放到 Github 或者 Gitlab 所属位置
4. 验证是否授权成功

ssh -T git@github.com 

2. 问题

Q1:

RROR: You’re using an RSA key with SHA-1, which is no longer allowed.
Please use a newer client or a different key type.
Please see https://github.blog/2021-09-01-improving-git-protocol-security-github/ for more information.

Answer: rsa 非对称加密不再被支持。换一个加密算法就行了。

ssh-keygen -t ecdsa -b 521 -C "your_email@example.com"

Q2:

Permissions 0640 for ‘/home/lrkqcd/.ssh/id_ecdsa’ are too open.
It is required that your private key files are NOT accessible by others.
This private key will be ignored.
Load key “/home/lrkqcd/.ssh/id_ecdsa”: bad permissions
Permission denied (publickey).
fatal: Could not read from remote repository.

Answer: 私钥权限的问题,只能文件所属用户有读权限。

chmod 600  id_ecdsa

Q3:

fatal: unable to access ‘https://github.com/zuohaimin/SSR_IMG.git/’: gnutls_handshake() failed: The TLS connection was non-properly terminated.

Answer: 一般来说是网络问题,被墙了。

//取消http代理
git config --global --unset http.proxy
//取消https代理 
git config --global --unset https.proxy

一般来说没啥用。

Q3:

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: POSSIBLE DNS SPOOFING DETECTED! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
The RSA host key for github.com has changed,
and the key for the corresponding IP address xx.xx.xx.xx
is unknown. This could either mean that
DNS SPOOFING is happening or the IP address for the host
and its host key have changed at the same time.
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that a host key has just been changed.

Answer: 上次连接过,主机唯一标识改变了。解决方法有两种:

  • 直接存档删除 .ssh 文件夹下面的 known_hosts 文件。
  • ssh-keygen -R 对应的ip地址

相关推荐

  1. 如何配置git的ssh

    2024-03-17 07:08:04       37 阅读
  2. 服务器配置 ssh 登录

    2024-03-17 07:08:04       35 阅读
  3. Github Gitlab SSH 配置

    2024-03-17 07:08:04       20 阅读
  4. Git的SSH配置

    2024-03-17 07:08:04       16 阅读
  5. Linux生成对并配置访问

    2024-03-17 07:08:04       6 阅读
  6. github / gitlab s申城 配置 ssh key

    2024-03-17 07:08:04       32 阅读

最近更新

  1. TCP协议是安全的吗?

    2024-03-17 07:08:04       18 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-03-17 07:08:04       19 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-03-17 07:08:04       18 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-03-17 07:08:04       20 阅读

热门阅读

  1. Elasticsearch快速检索的法宝: 倒排索引

    2024-03-17 07:08:04       22 阅读
  2. 数据挖掘与大数据的结合

    2024-03-17 07:08:04       19 阅读
  3. 记录一次业务遇到的sql问题

    2024-03-17 07:08:04       16 阅读
  4. 获取ArcGISPro中conda信息详情

    2024-03-17 07:08:04       19 阅读
  5. 指定函数为内置函数——个人练习

    2024-03-17 07:08:04       17 阅读
  6. unity-unity2d tilemap的基本使用笔记0.5.4000

    2024-03-17 07:08:04       17 阅读
  7. 七大排序(简洁思路版)

    2024-03-17 07:08:04       21 阅读