2

my apologies but i am at a loss. i tried following other instructions to no avail, and hope my post is clear enough that i will get good concise steps how to resolve:

i have a file test1.php in folder x. i have a Git Bash dialog opened in x/test1.php. here is some meta info; and i run the following commands with these results:

i have git version 2.12.1.windows.1. i created ssh key, named it id_rsa in .ssh folder:

ssh-add ~/.ssh/id_rsa

results in msg - Identity added in Users/profile/.ssh/id_rsa.

git push origin

results in msg - current branch master has no upstream branch, do this.... git push --set-upstream origin master results in Permission denied (publickey)...could not read from remote repo. furthermore, any attempts to follow through, not working....

git add test1.php
git commit -m "commit" test1.php
git push origin

then i get msg, "current branch master has no upstream branch...do this:"

git push --set-upstream origin master

that results in message: Permission denied (publickey). Could not read from remote repository. Please make sure you have access rights and the repo exists.

i generated an ssh private key earlier and added it, seemingly without incident. can you tell what is going wrong? can someone list simple, incremental steps on the natural order of the environment that makes this thing work?

i know there are other posts for this, i have read through them, and tried the collective things recommended. even if you could just point me to a post where things are sequentially laid out i could read that. any help, many thanks!!

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
dcparham
  • 291
  • 4
  • 17
  • Have you added the public key to the server where the remote repository is hosted? – ElpieKay Jun 01 '17 at 04:39
  • @ElpieKay-i used ssh-keygen, copied, pasted to bitbucket SSH Keys area. "git remote -v" shows both git...fetch, and git...push. then "git push origin" asks me to run "git push --set-upstream origin master". then that says repository does not exist. i just did it on my home computer, but this work pc not working. now, "ssh -Tv git@bitbucket.org" shows "Found key" and "Authentication succeeded(publickey) but git push results in "repo does not exist". man this is getting maddening. – dcparham Jun 02 '17 at 03:19
  • `git remote -v` should output something like `origin xxx_url_repo.git (fetch)` and `origin xxx_url_repo.git (push)`. If it's not, try `git push xxx_url_repo.git master:refs/heads/master`. If it is, try `git push origin master:refs/heads/master` – ElpieKay Jun 02 '17 at 03:50

1 Answers1

2

If git remote origin does show you an ssh url like git@aserver:auser/arepo, do test:

ssh -Tv git@aserver

You will see where ssh is looking for the public/private key. It should typically be %USERPROFILE%\.ssh\id_rsa

I have added other debugging tips here and in this answer.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • ssh -Tv git@github.com results in lots of statements including: reading configuration data...connection established.....Host 'github.com' is known and matches the RSA host key, Found key....Authentications that can continue: publickey...Offering RSA public key :/c/Users/dparham/.ssh/id_rsa...Trying pricate key [3 of them]... then LASTLY: "Permission denied (publickey". going in circles! feel like i have tried everything. added a remote, added key, push says to set upstream master, that says could not read from repo, then make sure i have access rights. grrrrr! – dcparham Jun 30 '17 at 21:26
  • @dcparham is your remote server a Gitlab one. GitHub? BitBucket? – VonC Jun 30 '17 at 21:33
  • @dcparham Is it a private repo? What does `ssh -T git@bitbucket.org` returns? – VonC Jul 01 '17 at 04:41
  • that returns "logged in as dparham_domainname." [domainname is our domain]. not sure if repo is private, but my home pc can push also to the 2nd directory [folder B], and my work pc can push to [only] folder A. – dcparham Jul 03 '17 at 13:01