說明
因為歷史原因,我係統裡有好些 SSH 祕鑰,想做清理但是年代很久遠:
$ ls -al ~/.ssh
total 176
drwxr-x--- 16 summer staff 512 2 20 17:06 .
drwxr-xr-x+ 80 summer staff 2560 2 20 17:19 ..
-rw-r-----@ 1 summer staff 6148 11 17 2016 .DS_Store
drwxr-x--- 2 summer staff 64 11 17 2016 .ssh
-rw-r-----@ 1 summer staff 1679 12 7 2013 bitbucket
-rw-r-----@ 1 summer staff 406 12 7 2013 bitbucket.pub
-rw-r-----@ 1 summer staff 34 10 6 2013 config
-rw-r-----@ 1 summer staff 1766 10 14 2013 github_rsa
-rw-r-----@ 1 summer staff 403 10 14 2013 github_rsa.pub
-rw-r-----@ 1 summer staff 404 10 14 2013 github_rsa.pub_bak-github
-rw-r-----@ 1 summer staff 1766 10 14 2013 github_rsa_bak-github
-r--------@ 1 summer staff 1679 10 6 2013 id_rsa
-rw-r-----@ 1 summer staff 406 9 13 2018 id_rsa.pub
-rw-r-----@ 1 summer staff 35382 9 28 17:34 known_hosts
-rw-r-----@ 1 summer staff 1675 10 6 2013 lgl
-rw-r-----@ 1 summer staff 424 10 6 2013 lgl.pub
問:如何辨別
git clone
命令時使用的是哪個祕鑰呢?
方法一:
除非你在 ~/.ssh/config
檔案中做了設定,預設情況下根據驗證協議不同會讀取以下:
~/.ssh/id_rsa
~/.ssh/id_dsa
~/.ssh/identity
方法二:
或者你也可以使用以下命令:
ssh -v git@github.com
-v
會顯示與伺服器建立連結的資訊。尋找關鍵詞 Offering
:
[...]
debug1: Offering RSA public key: /home/me/.ssh/id_rsa
debug1: Authentications that can continue: publickey
debug1: Offering RSA public key: /home/me/.ssh/id_rsa2
debug1: Server accepts key: pkalg ssh-rsa blen ****
[...]
本作品採用《CC 協議》,轉載必須註明作者和本文連結