Skip to content

Instantly share code, notes, and snippets.

@levpa
Created February 10, 2025 20:26
Show Gist options
  • Save levpa/080b4524215ebd510150cf89d580cdf1 to your computer and use it in GitHub Desktop.
Save levpa/080b4524215ebd510150cf89d580cdf1 to your computer and use it in GitHub Desktop.
SSH setup for GitHub and BitBucket in WSL2
# NOTE: we use Windows ssh.exe, thus all configuration must be on Windows side!
# all commands can be executed from WSL2 bash terminal
# ~/.gitconfig
[core]
editor = code --wait
sshCommand = ssh.exe
# Generate SSH keys in your teminal or use 1Password to store
# .ssh folder path for WSL2: /mnt/c/users/<user_name>/.ssh/
# /mnt/c/users/<user_name>/.ssh/config exapmle:
Host bitbucket.org
HostName bitbucket.org
User git
IdentityFile ~/.ssh/id_ed25519_bitbucket
IdentitiesOnly yes
Host github.org
HostName github.org
User git
IdentityFile ~/.ssh/id_ed25519_github
IdentitiesOnly yes
# gather pubic host keys to "known_hosts" file in Windows
touch /mnt/c/users/<user_name>/.ssh/known_hosts
ssh-keyscan.exe github.com >> /mnt/c/users/<user_name>/.ssh/known_hosts
ssh-keyscan.exe bitbucket.org >> /mnt/c/users/<user_name>/.ssh/known_hosts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment