ssh-keygen -t rsa -C eamil@qq.comgit
第一次生成時默認名稱爲 id_rsa
你願意改就改。github
.ssh
目錄下。若不作步須要在第二步時添加路徑名。id_rsa_
+ companyname把前2步生成的ssh文件分別添加到相應的網站。ssh
在.ssh文件夾下建立config文件(沒有後綴名)。
內容以下: 測試
# 配置github.com
Host github.com網站
HostName github.com IdentityFile C:\\Users\\popfisher\\.ssh\\id_rsa_github PreferredAuthentications publickey User username1
# 配置other.com
Host other.comcode
HostName other.com # 也能夠是ip地址。 IdentityFile C:\\Users\\popfisher\\.ssh\\id_rsa_oschina PreferredAuthentications publickey User username2
Host
設置在使用 git@
時後面的名字。 例: $ git clone git@other.com:repname/item.git HostName
設置域名地址或ip地址。 IdentityFile
輸入id_rsa的目錄地址。 PreferrenAuthentications
配置登陸時使用什麼僅限。可設爲 publickey
password publickey
keyboard-interactive
User
設置用戶名。須要與遠程的用戶名一致。ip
$ git config --global user.name "經常使用name"
$ git config --global user.email "經常使用email"
$ git config --local user.name "當前目錄使用的name"
$ git config --local user.email "當前目錄使用的email"域名
$ git config --global --list
$ git config --local --list // 查看當前目錄的配置信息it
$ ssh -T git@github.com // 測試是否能夠與github網站使用ssh交互。
$ ssh -T git@other.com // 測試是否能夠與other網站使用ssh交互。
// 提示成功就是成功。提示失敗就是失敗。io
整個配置過程就是使本地的用戶名、用戶郵箱、ssh與相應的遠程用戶名、用戶郵箱、ssh相對應。
如有任一不對應則不能正常運行。
2018.09.18 by stone