日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 综合教程 >内容正文

综合教程

Windows免密登录Linux + 配置多个Github账号

發(fā)布時(shí)間:2024/8/26 综合教程 35 生活家
生活随笔 收集整理的這篇文章主要介紹了 Windows免密登录Linux + 配置多个Github账号 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

就當(dāng)【碎碎】平安了,忘掉不愉快,今天分享兩個(gè)超簡(jiǎn)單、超實(shí)用的Window實(shí)用技能。

三步完成windows免密登錄linux

1)在windows上生成秘鑰:

啟動(dòng)Git, ssh-keygen -t rsa -C "xxx@163.com", 生成秘鑰:id_rsa.pub, id_rsa

默認(rèn)生成在C盤:

C:\Users\DELL\.ssh 的目錄2022/04/07 09:43

.2022/04/07 09:43 ..2022/04/07 09:43 54 config2019/04/27 07:21 1,831 id_rsa2019/04/27 07:21 401 id_rsa.pub2022/06/11 15:02 2,138 known_hosts 4 個(gè)文件 4,424 字節(jié) 2 個(gè)目錄 19,970,998,272 可用字節(jié)

2)上傳秘鑰到linux服務(wù)器:

復(fù)制公鑰 id_rsa.pub 的全部?jī)?nèi)容到服務(wù) .ssh/authorized_keys當(dāng)中,保存authorized_keys。

3) 啟動(dòng) ssh server:

啟動(dòng)命令:service sshd restart, 然后windows 退出linux服務(wù)器登錄后重新登錄即可完成免密登錄了。

2.一臺(tái)Windows電腦,配置多個(gè)Github賬號(hào)、實(shí)現(xiàn)代碼上傳

一臺(tái)Windows電腦,怎么配置多個(gè)Github賬號(hào),實(shí)現(xiàn)代碼上傳呢?我們分享在 windows10上同時(shí)創(chuàng)建 paperClub-hub 和 user2items 兩個(gè)Github賬號(hào), 其實(shí)整個(gè)過程只用三步。


1)生成秘鑰

打開Git, 檢查C盤根目錄下有沒有 .ssh文件夾,如果沒有自己創(chuàng)建一下就可以了。我們先生成兩個(gè)秘鑰 is_rsa_paperClub-hub 和 is_rsa_user2items:

ssh-keygen -t rsa -f is_rsa_paperClub-hub
ssh-keygen -t rsa -f is_rsa_user2items

直接回車,其他不用管,這樣就生成了秘鑰,is_rsa_paperClub-hub 和 is_rsa_user2items是為了舉例子,大家可以根據(jù)自己的需要?jiǎng)?chuàng)建 。

DELL@DESKTOP-IDPMAV4 MINGW64 ~/.ssh$ lsconfig id_rsa.pub id_rsa_paperClub-hub.pub id_rsa_user2items.pubid_rsa id_rsa_paperClub-hub id_rsa_user2items known_hosts

2)上傳公鑰到Github
這一步比較簡(jiǎn)單:打開登錄github 賬號(hào)(以paperClub-hub為例) , 點(diǎn)擊github右上角的頭像-->settings --> SSH and GPG keys 中,然后再點(diǎn)擊“new SSH key”,

設(shè)置SSH keys Title, 然后編輯器打開剛才生成的 id_rsa_paperClub-hub.pub 文件,復(fù)制全部?jī)?nèi)容到 SSH keys Key: 下的空白框內(nèi)(github賬號(hào)和公鑰對(duì)應(yīng),別混了),然后點(diǎn)擊 “add SSH Key”就完成了Github秘鑰的配置。

驗(yàn)證:

$ssh -T git@user2items.github.com
Hi user2items! You've successfully authenticated, but GitHub does not provide shell access.
$ssh -T git@paperClub-hub.github.com
Hi paperClub-hub! You've successfully authenticated, but GitHub does not provide shell access.

以上說明配置完成。

3)本地配置及驗(yàn)證
在C盤創(chuàng)建一個(gè)config文件(如果沒有的話),內(nèi)容:

Host paperClub-hub.github.com
HostName github.com
User paperClub-hub
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa_paperClub-hub

Host user2items.github.com
HostName github.com
PreferredAuthentications publickey
User user2items
IdentityFile ~/.ssh/id_rsa_user2items

配置其實(shí)目的就是為了方便管理,當(dāng)然也可以不做。我們這樣做就是盡可能的和github上的url保持一致,比如 Host 和 HostName。> 郵箱及用戶配置,這個(gè)先重置全局信息,然后分布進(jìn)行配置,比較簡(jiǎn)單。>然后用Git進(jìn)入本地的git的文件夾。創(chuàng)建 本地倉(cāng)儲(chǔ): git init> 關(guān)聯(lián)遠(yuǎn)端:

https:

$ git remote add origin https://github.com/user2items/paperClub.git

ssh:

$ git remote add origin git@github.com: user2items/paperClub.git

上面的 github.com為 config中的 HostName, 后面緊接著是用戶名和遠(yuǎn)端的倉(cāng)儲(chǔ)位置,我們仔細(xì)看一下,其實(shí)就是githup上 https的 URL : https://github.com/user2items/paperClub.git> 拉去遠(yuǎn)端代碼:

$ git pull origin master
From https://github.com/user2items/paperClub

  • branch master -> FETCH_HEAD
  • [new branch] master -> origin/master
    Already up to date.

> 上傳代碼:

$ git push origin master
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 8 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 353 bytes | 353.00 KiB/s, done.
Total 3 (delta 2), reused 0 (delta 0)
remote: Resolving deltas: 100% (2/2), completed with 2 local objects.
remote:
remote: GitHub found 32 vulnerabilities on user2items/paperClub's default branch (1 critical, 14 high, 15 moderate, 2 low). To find out more, visit:
remote: https://github.com/user2items/paperClub/security/dependabot
remote:
To https://github.com/user2items/paperClub.git
a7abd55..d86c781 master -> master

`

怎么樣,是不是很簡(jiǎn)單呢?

總結(jié)

以上是生活随笔為你收集整理的Windows免密登录Linux + 配置多个Github账号的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。