1

I Set up git server on an remote instance with git init --bare in directory named stockwidgets.

Also, set up ssh with remote key access correctly.

ssh access works as follows:

---------------------------------------------
$ ssh -i ~/.ssh/keys/gitKey.pvt git@www.stockwidgets.com
Last login: Sat Jan 26 22:43:10 2019 from toroon3642w-lp130-01-70-27-142-166.dsl.bell.ca

[git@ip-172-31-8-112 ~]$
---------------------------------------------

So ssh access works from my local PC, however???

Also the repository exists in the home directory as follows:

[git@ip-172-31-8-112 ~]$ ls
stockwidgets
------------------------------------------

The git remote is set correctly as:

git remote -v
origin  ssh://git@www.stockwidgets.com/stockwidgets (fetch)
origin  ssh://git@www.stockwidgets.com/stockwidgets (push)

however remote git commands fail as follows:

$ git fetch
Permission denied (publickey,gssapi-keyex,gssapi-with-mic).
fatal: Could not read from remote repository.

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

The repository does exist as I can use it on the remote.
Access has to be the issue through ssh git.

Lost sole .....

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
  • 2
    The thing that stands out here is that from the command line, you're running `ssh -i ~/.ssh/keys/gitKey.pvt ...`. Git is going to run `ssh ...`, with no `-i` flag. So it's only going to use whatever is in `$HOME/.ssh/config` and/or `$HOME/.ssh/id_{dsa,rsa}`. (If the `config` file points that ssh to the appropriate key, that should still work. If not...) – torek Jan 26 '19 at 23:03

2 Answers2

1

Thanks, VonC

Very much appreciated, however, I used a different solution.

Basically, I stated my remote path incorrectly. I had to give the complete path. That was the issue.

ssh://git@www.stockwidgets.com/home/git/REPOSITORIES/stockwidgets/springBoot/microServices/swAPIEngine.

Fixed

0

If you don't use an ~/.ssh/config file which would indicate which SSH key to use, you would need, with Git 2.10+, to set an GIT_SSH_COMMAND variable

export GIT_SSH_COMMAND='ssh -i /path/to/private_key'
# on Windows
set GIT_SSH_COMMAND='ssh -i /c/path/to/private_key'

Note: on PC, make sure to use a PEM ssh private key (ssh-keygen -m PEM ...).

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250