Tricks

VsCode bitbucket git using ssh key

If you are using bitbucket git on VsCode, then you can add ssh key to make everything easier.

Generate a Key:

Use ssh-gen or PuttyGen to generate an SSH Key pair: private and public.

https://support.atlassian.com/bitbucket-cloud/docs/set-up-an-ssh-key/

Private key stays with you and public key stays on the Bitbucket server.

Add Key to BitBucket

Go to BitBucket Settings -> Personal -> SSH Keys

Click on Add Key and paste your public key here

Make sure to add the Private Key ppk to Pagent app. On windows it gets installed with Putty.

Still not resolved:

Make sure to add GIT_SSH and GIT_SSH_COMMAND environment variables to your system variables.

And for value, use the ssh.exe you are using. For example, if you have OpenSSH installed then add:

C:\Windows\System32\OpenSSH\ssh.exe

After adding any new env vars, you need to restart system.

Or if you have putty and use it’s plink as ssh, then add:

C:\path to putty\plink.exe

Suppose, you have TortoiseGit installed and you need it’s ssh, then use:

C:\Program Files\TortoiseGit\bin\TortoiseGitPlink.exe

Or you can also open git global settings in TortoiseGit:

And add your ssh path under core:

[core]
	sshCommand = C:\\Program Files\\TortoiseGit\\bin\\TortoiseGitPlink.exe

If core doesn’t exist, then add it.

And also check Tortoise Git settings to make sure the path is correct. In it’s Network section:

Best way to check the SSH path of your whole Git installation, is to open your Git CMD and type:

where ssh

C:\Windows\System32\OpenSSH\ssh.exe

Then use this to change the ssh that git uses:

Error in VsCode

git push origin master:master
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

This error means that there might be some problem with Pageant. Check if private key added is the correct one matching your Public key on BitBucket

Leave a Reply

Your email address will not be published. Required fields are marked *