Developing with Git and SSH
Arch Linux
Install ksshaskpass
and create a symlink to enable VS Code to recognise it:
sudo pacman -Syu openssh kwalletmanager kwallet-pam ksshaskpass git-lfs
sudo ln /usr/bin/ksshaskpass /usr/lib/ssh/ssh-askpass
git config --global user.name "Your Name"
git config --global user.email "email@example.com"
Check for existing SSH keys:
ls -al ~/.ssh
If no keys exist, generate a new key using ED25519 (recommended over RSA):
ssh-keygen -t ed25519 -C "<comment>"
Start the SSH agent as follows (also add these to ~/.bashrc
or equivalent):
eval $(ssh-agent)
ssh-add
Copy the SSH public key to your clipboard (saved at ~/.ssh/id_ed25519.pub
) and add to GitHub/GitLab. The key can be used for authentication, signing, or both.
Configure SSH key for signing commits:
git config --global commit.gpgsign true
git config --global gpg.format ssh
git config --global user.signingkey ~/.ssh/id_ed25519.pub
In VS Code / VSCodium, enable commit signing in the settings:
"git.enableCommitSigning": true
Windows Subsystem for Linux (WSL) - Ubuntu
In PowerShell, install Visual Studio Code and WSL (Ubuntu):
winget install vscode
wsl --install
Install the WSL and Remote - SSH VS Code extensions locally in Windows.
Set up SSH (for authentication and signing) and Git using the WSL Bash shell (this is identical to setting up SSH on Ubuntu):
sudo apt install ssh-askpass keychain git-lfs
ssh-keygen -t ed25519 -C "<comment>"
eval "$(ssh-agent -s)"
eval `keychain --eval`
ssh-add
git config --global user.name "Your Name"
git config --global user.email "email@example.com"
git config --global commit.gpgsign true
git config --global gpg.format ssh
git config --global user.signingkey ~/.ssh/id_ed25519.pub
Add the following to WSL’s ~/.bashrc
:
eval "$(ssh-agent -s)"
eval `keychain --eval`
ssh-add
Copy the SSH public key to your clipboard (saved at ~/.ssh/id_ed25519.pub
) and add to GitHub/GitLab. The key can be used for authentication, signing, or both.
Install packages such as Miniconda using the WSL Bash shell (use the Unix shell script to install).
Clone Git repositories using the WSL Bash shell using SSH.
Launch VS Code using the WSL Bash shell by navigating to the Git repository directory and running code .
.
Install local VS Code extensions in WSL.
Windows without WSL
In PowerShell:
winget install vscode
winget install git.git
winget install github.githubdesktop
winget install github.cli
winget install github.gitlfs
git config --global user.name "Your Name"
git config --global user.email "email@example.com"
Authenticate GitHub Desktop and GitHub CLI using your GitHub account.
[Optional] If there are any issues running PowerShell scripts, update the execution policy:
Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy RemoteSigned
[Optional] To also sign commits using an SSH key, do the following:
-
Create a new SSH key pair with
ssh-keygen -t ed25519 -C "<comment>"
in Git Bash (alternatively, copy the key pair created in WSL into~/.ssh
):ssh-keygen -t ed25519 -C "<comment>"
-
Then, in Git Bash:
eval $(ssh-agent) ssh-add git config --global commit.gpgsign true git config --global gpg.format ssh git config --global user.signingkey ~/.ssh/id_ed25519.pub
-
Add the following to
~/.bashrc
:eval $(ssh-agent) ssh-add
-
Copy the SSH public key to your clipboard (saved at
~/.ssh/id_ed25519.pub
) and add to GitHub/GitLab. The key can be used for authentication, signing, or both. -
Note: this may not work, so try OpenSSH for Windows instead of the SSH that comes with Git.
-
Set OpenSSH to run automatically. Go to Task Manager > Services > Open Services, find OpenSSH Authentication Agent > Properties > Startup Type > Automatic.
-
Configure Git to use OpenSSH (in Git Bash):
git config --global core.sshCommand "C:/Windows/System32/OpenSSH/ssh.exe" eval $(ssh-agent) ssh-add
-
To revert to the SSH agent supplied by Git for Windows (in Git Bash):
git config --global core.sshCommand "C:/Program Files/Git/usr/bin/ssh.exe" eval $(ssh-agent) ssh-add
Links
- https://learn.microsoft.com/en-us/windows/wsl/
- https://code.visualstudio.com/docs/remote/wsl
- https://docs.gitlab.com/ee/user/ssh.html
- https://support.atlassian.com/bitbucket-cloud/docs/set-up-personal-ssh-keys-on-windows/
- https://docs.github.com/en/github/authenticating-to-github/connecting-to-github-with-ssh
- https://docs.github.com/en/get-started/getting-started-with-git/managing-remote-repositories
Leave a comment
Your email address will not be published. Required fields are marked *.