Skip to content

Instantly share code, notes, and snippets.

@lewangdev
Last active November 21, 2023 10:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lewangdev/288205ecf6dd2fe593db4aebac850a14 to your computer and use it in GitHub Desktop.
Save lewangdev/288205ecf6dd2fe593db4aebac850a14 to your computer and use it in GitHub Desktop.
how-to-add-ssh-public-keys

推荐 通过 ssh-import-id 命令导入 ssh 公钥

$ sudo apt install -y ssh-import-id
$
$ ssh-import-id-gh lewangdev
2023-11-21 09:29:24,308 INFO Authorized key ['2048', 'SHA256:Pu/8zz7rT6zKH0aklqk+7j1XNqAfB7COIan4Kryo3+Y', 'lewangdev@github/8809471', '(RSA)']
2023-11-21 09:29:24,313 INFO Authorized key ['3072', 'SHA256:2/aQDHc+ULG3moyvTr9h3702Btb49I5Y3UGKf7kqJRI', 'lewangdev@github/61522538', '(RSA)']
2023-11-21 09:29:24,318 INFO Authorized key ['256', 'SHA256:oLZ91UAqwhQgnb7wC+NrgEAYq+sxg9xmLCrI6t+N93M', 'lewangdev@github/66075094', '(ED25519)']
2023-11-21 09:29:24,323 INFO Authorized key ['256', 'SHA256:ymuGSnvAOSrJylWtaFVVGARv+AcsKnrG+B3HHptXews', 'lewangdev@github/75841698', '(ED25519)']
2023-11-21 09:29:24,324 INFO [4] SSH keys [Authorized]

通过下载 https://github.com/.keys 到 ~/.ssh/authorized_keys

$ export GITHUB_USERNAME=lewangdev
$ wget -O - https://github.com/${GITHUB_USERNAME}.keys | tee -a ~/.ssh/authorized_keys
$ chmod 600 ~/.ssh/authorized_keys
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment