ubuntu 通过 SSH 连接 Github

本文源自ubuntu git 环境搭建以及通过 SSH 连接 Github - 知乎

做了少量更改,自用。

Git 本地环境配置1. 安装 git

sudo apt-get install git

2. 配置用户信息

$ git config --global user.name "Your Name"
$ git config --global user.email Your_email@example.com

3. 初始化本地仓库配置

git init

通过 SSH 连接 Github1. 安装 SSH

sudo apt-get install ssh

首先 ssh-keygen 会确认密钥的存储位置和文件名(默认是 .ssh/id_rsa), 然后他会要求你输入两次密钥口令,留空即可。所以一般选用默认,全部回车即可。

2. 创建密钥文件

ssh-keygen -t rsa -C "你的github账号邮箱"

默认密钥文件路径在~/.sshid_rsa 是私钥文件,id_rsa.pub 是公钥文件

3. 将公钥添加到 Github

cat ~/.ssh/id_rsa.pub

id_rsa.pub 文件内容全部复制

登陆到 GitHub 上,右上角小头像 ->Setting->SSH and GPG keys 中,点击 new SSH key。

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
要在Ubuntu连接GitHub,你需要按照以下步骤进行操作: 1. 首先,安装Git。在终端中运行以下命令来安装Git: ``` sudo apt-get install git ``` 2. 创建SSH密钥对。在终端中运行以下命令来生成SSH密钥对: ``` ssh-keygen -t rsa -b 4096 -C "your_email@example.com" ``` 3. 将公钥添加到GitHub账户。使用以下命令将公钥复制到剪贴板: ``` cat ~/.ssh/id_rsa.pub | xclip -selection clipboard ``` 然后,登录到GitHub账户,转到"Settings" -> "SSH and GPG keys" -> "New SSH key",将公钥粘贴到"Key"字段中,并为该密钥提供一个描述性的标题。 4. 配置Git。在终端中运行以下命令来配置Git的用户名和邮箱地址: ``` git config --global user.name "your_username" git config --global user.email "your_email@example.com" ``` 5. 其他操作。你可以使用以下命令进行其他常见的Git操作: - 初始化一个新的Git仓库: ``` git init ``` - 克隆一个现有的Git仓库: ``` git clone https://github.com/your_username/repository.git ``` - 将文件添加到Git缓存: ``` git add file_name ``` - 提交更改到Git仓库: ``` git commit -m "commit_message" ``` - 将本地仓库与远程仓库建立连接: ``` git remote add origin https://github.com/your_username/repository.git ``` 请注意,上述命令中的"your_username"和"your_email@example.com"应替换为你自己的GitHub用户名和邮箱地址。 #### 引用[.reference_title] - *1* *2* *3* [在Ubuntu使用Git访问Github](https://blog.csdn.net/qq_42276781/article/details/124504966)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值