项目作者: huyndao

项目描述 :
How to set up U2F/FIDO2 hardware security key to use with SSH and Github
高级语言:
项目地址: git://github.com/huyndao/u2f-fido2-security-key-ssh-github.git
创建时间: 2021-09-02T20:17:37Z
项目社区:https://github.com/huyndao/u2f-fido2-security-key-ssh-github

开源协议:MIT License

下载


How to set up U2F/FIDO2 hardware security key to use with SSH and Github

Generate ssh key pair

  1. $ ssh-keygen -C 'your.email@provider.com' -f $HOME/.ssh/user-github -t ed25519-sk
  2. Generating public/private ed25519-sk key pair.
  3. You may need to touch your authenticator to authorize key generation.
  4. Enter PIN for authenticator: ****************
  5. You may need to touch your authenticator (again) to authorize key generation.
  6. Enter passphrase (empty for no passphrase):
  7. Enter same passphrase again:
  8. Your identification has been saved in /home/$USER/.ssh/user-github
  9. Your public key has been saved in /home/$USER/.ssh/user-github.pub
  10. The key fingerprint is:
  11. SHA256: <hash> your.email@provider.com

It is probably more convenient to use an empty passphrase.

Copy public key

  1. $ xclip -i -sel clip < $HOME/.ssh/user-github.pub

Add public key to GitHub

Go to https://github.com/settings/keys, click on New SSH key and paste key and save

Update $HOME/.ssh/config with the following

  1. Host github.com
  2. Hostname ssh.github.com
  3. Port 443
  4. User git
  5. IdentityFile %d/.ssh/user-github
  6. IdentitiesOnly yes

Test ssh connection to GitHub

  1. $ ssh -T git@github.com
  2. Confirm user presence for key ED25519-SK SHA256: <hash>
  3. Hi user! You've successfully authenticated, but GitHub does not provide shell access.

Set up your repository with the appropriate URL

  1. $ git remote set-url origin git@github.com:username/your-repository.git

Now you’re ready to add files, commit, push/pull!

  1. $ git remote show origin
  2. Confirm user presence for key ED25519-SK SHA256: <hash>
  3. * remote origin
  4. Fetch URL: git@github.com:username/your-repository.git
  5. Push URL: git@github.com:username/your-repository.git
  6. HEAD branch: main
  7. Remote branch:
  8. main tracked
  9. Local branch configured for 'git pull':
  10. main merges with remote main
  11. Local ref configured for 'git push':
  12. main pushes to main (up to date)

References