Can't push to remote SSH repo on GitHub via VSCode

Can't push to remote SSH repo on GitHub via VSCode



I already updated my Git for Windows. I checked the keys are correct. The only "solution" is to start


ssh-agent



Or opening VSCode via Git Bash.



So, any useful solution?



Log:


> git push origin master:master
git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.

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






Force pushes might be disabled on the master branch. Check the settings on the repo that you're trying to push to.

– Madhu Bhat
Sep 13 '18 at 3:22






What Madhu said plus: help.github.com/articles/…

– tymtam
Sep 13 '18 at 3:23






@tymtam I already did what the article says with no avail. Also, how exactly do I enable 'Force push'?

– dawn
Sep 13 '18 at 3:32






Force push: git push --force

– tymtam
Sep 13 '18 at 4:07







@tymtam yeah, I can push it via console, but I want to use VSCode GUI.

– dawn
Sep 13 '18 at 4:10




2 Answers
2



Force push might be disabled on the master branch. Check the settings on the repo that you're trying to push to.



If force push on master is not disabled, you need to make sure that you have added your ssh key path on your ssh config, so that you don't have to add the ssh key to the session every time. Edit the config file at ~/.ssh/config and add the below (on MacOS)


config


~/.ssh/config


Host *
UseKeychain yes
AddKeysToAgent yes
IdentityFile ~/path/to/key



For Windows, please check my SO answer to know how to add the ssh key to the ssh config.



UPDATE



Looks like there's an open issue with VS Code on Windows here. You may try the workaround that is mentioned here.






And for Windows?

– dawn
Sep 13 '18 at 3:32






@dawn added to the answer. Please check my SO answer for the steps to add it on Windows.

– Madhu Bhat
Sep 13 '18 at 3:34







@dawn Are you sure there is no # before IdentityFile ~/.ssh/id_rsa? Since the # can comment the line.

– Madhu Bhat
Sep 13 '18 at 3:37



#


IdentityFile ~/.ssh/id_rsa






@dawn then force push is not disabled. Also, the ssh config should have the local path to your ssh key and not ~/.ssh/id_rsa. If your ssh key is in D:ssh_key, you should add the line IdentityFile D:ssh_key to the ssh config.

– Madhu Bhat
Sep 13 '18 at 3:43


~/.ssh/id_rsa


IdentityFile D:ssh_key






@dawn looks like there's an open issue with vscode github.com/Microsoft/vscode/issues/13680. You may try this workaround that someone has mentioned here github.com/Microsoft/vscode/issues/13680#issuecomment-414841885

– Madhu Bhat
Sep 13 '18 at 4:05



There are many ways you can make your ssh key (with a passphrase) works in the gitbash terminal for VS Code. I'll let you look around to find it if you didn't.



I assume you did look around and are still stuck because you want to use the UI of VSCode.



If so, this official page tells you why :



Basically, you'll still have to run it via git bash or via running ssh-agent.


ssh-agent



But you can bypass the situation using putty. I didn't try it myself.



Anyway : hope it'll help.



Thanks for contributing an answer to Stack Overflow!



But avoid



To learn more, see our tips on writing great answers.



Required, but never shown



Required, but never shown




By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

Crossroads (UK TV series)

ữḛḳṊẴ ẋ,Ẩṙ,ỹḛẪẠứụỿṞṦ,Ṉẍừ,ứ Ị,Ḵ,ṏ ṇỪḎḰṰọửḊ ṾḨḮữẑỶṑỗḮṣṉẃ Ữẩụ,ṓ,ḹẕḪḫỞṿḭ ỒṱṨẁṋṜ ḅẈ ṉ ứṀḱṑỒḵ,ḏ,ḊḖỹẊ Ẻḷổ,ṥ ẔḲẪụḣể Ṱ ḭỏựẶ Ồ Ṩ,ẂḿṡḾồ ỗṗṡịṞẤḵṽẃ ṸḒẄẘ,ủẞẵṦṟầṓế