首页 > 其他分享 >来玩 GitHub 啊,SSH 连接方式

来玩 GitHub 啊,SSH 连接方式

时间:2024-05-20 22:31:25浏览次数:15  
标签:git 连接 github GitHub SSH your ssh

Windows 11

git version 2.32.0.windows.2

GitHub 20240520

--

 

今天找回了自己的 GitHub 账号密码,继续玩吧,再次加入 蓝星的开源软件基地。

使用邮箱注册的,找回密码也很方便。

 

本文简要展示 按照官方文档的介绍 使用 SSH 连接 GitHub 的过程。

简述为:

  1. 创建SSH密钥对
  2. 公钥注册到GitHub,2次
  3. 测试SSH密钥对
  4. 创建仓库
  5. 拉取仓库
  6. 提交代码

 

主要文档

1、Connecting to GitHub with SSH

https://docs.github.com/en/authentication/connecting-to-github-with-ssh

  1. About SSH
  2. Using SSH agent forwarding
  3. Managing deploy keys
  4. Checking for existing SSH keys
  5. Generating a new SSH key and adding it to the ssh-agent
  6. Adding a new SSH key to your GitHub account
  7. Testing your SSH connection
  8. Working with SSH key passphrases

 

2、Getting started with Git

https://docs.github.com/en/get-started/getting-started-with-git

  1. Set up Git
  2. Setting your username in Git
  3. Caching your GitHub credentials in Git
  4. Why is Git always asking for my password?
  5. Updating credentials from the macOS Keychain
  6. Git workflows
  7. About remote repositories
  8. Managing remote repositories
  9. Associating text editors with Git
  10. Configuring Git to handle line endings
  11. Ignoring files
  12. Git cheatsheet

 

使用 SSH 连接 GitHub

文档1 下面的 “E. Generating a new SSH key and adding it to the ssh-agent”。

生成密钥对文件命令:公钥、私钥

ssh-keygen -t ed25519 -C "[email protected]"

注,如果密钥对文件已存在,则替换;也可以在 提示“Enter file in which to save the key (/c/Users/YOU/.ssh/id_ALGORITHM):[Press enter]”时输入不同的。

注,在提示,“Enter passphrase (empty for no passphrase): [Type a passphrase]”时,直接按下 回车键, 意味着没有 passphrase,存在安全风险。

上面命令执行后,在 HOME 目录的 .ssh 目录下生成了 下面两个文件:

  • id_ed25519 私钥
  • id_ed25519.pub 公钥

其中,公钥 需要添加到 GitHub 网站,见文档1 的 “F. Adding a new SSH key to your GitHub account”。

https://docs.github.com/en/authentication/connecting-to-github-with-ssh/adding-a-new-ssh-key-to-your-github-account

说明,SSH key 有两个用途,认证 和 上传代码等,每次添加,都只能选择一个用途,因此,需要添加两次——不过,两次可以是同一个公钥。

Authentication keys 和 Signing keys。

验证是否配置成功

见文档1  的 “G. Testing your SSH connection”。

https://docs.github.com/en/authentication/connecting-to-github-with-ssh/testing-your-ssh-connection

执行命令:

ssh -T [email protected]

说明,第一次会出现很长一串信息,输入 yes 即可。在执行一次,信息就简单了。两次执行的输出信息末尾都有:

Hi xxx! You've successfully authenticated, but GitHub does not provide shell access.

--xxx 是 用户名。

 

关于 ssh-agent

在 设置了 密钥对的  passphrase 时,可以使用 ssh-agent 进行管理。

避免每次操作都要输入 passphrase。

安全相关,重要。

 

 

使用代码仓库

见文档2 中的内容。

安装 git软件,略。

 

git配置

见文档2 的 “B. Setting your username in Git”:

https://docs.github.com/en/get-started/getting-started-with-git/setting-your-username-in-git

命令:

git config --global user.name "Mona Lisa"
$ git config --global user.name
--全局
git config user.name "Mona Lisa"
$ git config user.name
--单个库 进入 库目录

 

见文档“Setting your commit email address”:

命令:

git config --global user.email "YOUR_EMAIL"

$ git config --global user.email

--全局

git config user.email "YOUR_EMAIL"

$ git config user.email

--单个库 进入 库目录

注意,其中有提到“a GitHub-provided noreply email address”,GitHub提供的无回复邮件地址。可以配置到Git仓库中。

这个邮件地址的格式也在文档中有介绍,新的是“[email protected]”,如下:

注,ID找了半天没找到,最后拉取仓库后,使用 git log -3 命令看到了,而且这里的 加号 是真的存在的。

 

创建仓库

在 GitHub 官网,登录后创建,很方便。

 

拉取仓库到本地:SSH

选择 仓库的 Local - SSH 地址:

执行 git clone 拉取到本地 即可。

git clone [email protected]:xxx/hello-world.git

--

拉取后,配置 git 的 user.name、user.email

ben发布于博客园

提交代码到GitHub

命令提交 或 IDE提交,皆可。

不再赘述。

 

END

 

本文链接:

https://www.cnblogs.com/luo630/p/18202797

 

ben发布于博客园

ben发布于博客园

 

标签:git,连接,github,GitHub,SSH,your,ssh
From: https://www.cnblogs.com/luo630/p/18202797

相关文章

  • 关于Linux OpenSSH登录的问题
    OpenSSH由7.6升级到8.2和9.0之后用密码登录登不上去了,提供以下思路:1、7.6之前的版本SSH启动路径为/usr/local/sbin/sshd,7.6之后的版本启动路径为/usr/sbin/sshd,控制启动文件为vi/etc/rc.d/init.d/sshd 2、检查SSH服务的配置文件 /etc/ssh/sshd_config。确保没有设置 Passwo......
  • mysql允许其它机器连接
    1.修改MySQL的配置文件(windows是my.ini,linux是my.cn.cnf或my.cnf),如果有bind-address这一行,值改为0.0.0.0,这样可以允许任意IP地址连接到MySQL服务器。bind-address=0.0.0.0没有bind-address,就补上bind-address=0.0.0.0这一行2.修改权限grantallprivilegeson*.*to'r......
  • springboot的服务不需要连接数据库,如何保证正常启动
    记个小笔记@SpringBootApplication(exclude=DataSourceAutoConfiguration.class)是一个SpringBoot应用程序中用来排除特定自动配置类的注解,一般情况不需要使用数据库,取消这个自动配置即可;如果你这样做了,发现还是出现FailedtoconfigureaDataSource:'url'attributeisn......
  • ssh的空闲超时断开会话方法及反空闲(保持连接)方法
    两种方式:1.设置TMOUT,在用户家目录下设置只针对本用户,在/etc/profile里设置针对全部这个是针对所有tty的,所以本地和ssh超时都会退出注意:大多数的shell客户端工具,如putty,windterm,mobaxterm等里面的保持会话功能,只发送空包,是无法针对TMOUT起作用的tmout命令只对交互式s......
  • ssh_key验证单台机器管理后端机器
    机器互通[root@k8s-deploy:~]#ssh-keygen-trsa-sha2-512-b4096[root@k8s-deploy:~]#aptinstallsshpass#安装sshpass命令⽤于同步公钥到各k8s服务器[root@k8s-deploy:~]#vimkey-scp.sh########(51、52、532为k8smaster)(56、57、58为k8s集群中的etcd)(60、61、62为node......
  • git切换连接方式(ssh-https)
      要将git仓库的ssh链接切换为https链接,可以按照以下步骤操作: 1.打开终端,并进入到本地的git仓库目录中。 2.使用以下命令查看当前git仓库的远程链接:gitremote-v3.使用以下命令移除当前的ssh远程链接:gitremoteremoveorigin4.使用以下命令添加https远程链......
  • 配置SQLServer远程连接
    要在SQLServer上启用远程连接,需要执行以下步骤:1、确保SQLServer已启用远程连接:登录到SQLServer所在的计算机上。打开SQLServerManagementStudio(SSMS)。使用Windows身份验证或SQLServer身份验证登录SQLServer。在左侧的对象资源管理器中,右键单击服务......
  • VirtualBox虚拟机远程桌面连接设置详解(包含登录密码设置)
    一、安装VirtualBox虚拟机下载与安装:访问VirtualBox官方网站,根据您的操作系统(如Linux、Windows、Mac等)下载对应版本的VirtualBox安装包。安装下载的VirtualBox软件。创建虚拟机:打开VirtualBox,点击“新建”按钮,按照向导创建新的虚拟机。例如,命名为“Winxp”。根据您的......
  • 给github新增讨论功能
    给github新增讨论功能giscus讨论功能说明https://giscus.app/zh-CNgiscusGitHubhttps://github.com/giscus/giscus/blob/main/README.zh-CN.md......
  • 连接池设计与实现一——以Golang Http1.1为例
    0.前言连接池是一个非常重要的开发思想,如httpclient会构建连接池复用底层TCP连接,使用database/sql的使用也会有连接池的配置。那么代码底层是如何实现连接池的呢?这篇文档将以Golang语言为基础,分析http1.1连接池底层实现★注意:我们仅仅关注连接池设计思想、以及关键源码解读,......