简体   繁体   中英

Git connect using ssh on windows

I have read some questions around but still didn't found the solution to this problem

I have git on windows and I want to connect to github using ssh. Following this tutorial https://help.github.com/articles/generating-ssh-keys I have successfully setup my keys

If I open a git-bash and try to ssh github I am able to connect, so this works

ssh -T git@github.com
Hi username! You've successfully authenticated, but GitHub does not
provide shell access.

this means that git-bash actually sees my keys. However if I try to do a push

git push origin master

git prompts me for username and password
Thank you for your help

EDIT: solved by using the git protocol instead of the http protocol, my fault
so replace this

https://github.com/_user_/_repository_.git  

whit this

git@github.com:_user_/_repository_.git  

in the remote link

无需删除/添加,只需执行以下操作:

git remote set-url origin git@github.com:username/repo.git

You probably cloned a remote that uses the https protocol, rather than the git protocol. You need to redefine your remote for origin .

# Change this as needed.
github_username="$LOGNAME"

# Replace your remote, then push.
git remote rm origin
git remote add origin "git@github.com:${github_username}/${PWD##*/}.git"
git push --tags --set-upstream origin master

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM