3

I have a problem pushing to my Gitlab account via SSH, since I moved the key pair in the different folder.

Consequently after pushing in the remote I got an "access denied" error, which I assume is connected to the fact that ssh tries to use standard id_rsa in .ssh folder.

Here, I found a way to clone repo using non-standard path to the private SSH key. Now I want to make it default for a given repo using (from Git-scm):

git config core.sshCommand='ssh -i path/to/the/key/privatkeyfilename'

I get and error:

invalid key: core.sshCommand=ssh -i path/to/the/key/privatkeyfilename

Am I doing something wrong? How to achieve this?

Thân LƯƠNG Đình
  • 3,082
  • 2
  • 11
  • 21
kek
  • 57
  • 6

1 Answers1

6

I think you remove =. You could use following correction.

git config core.sshCommand 'ssh -i path/to/the/key/privatkeyfilename'
Thân LƯƠNG Đình
  • 3,082
  • 2
  • 11
  • 21
  • now command seems to work (no error appeared). But when pushing I get "Warning: Identity file path/to/the/key/privatkeyfilename not accessible: No such file or directory." I checked multiple times the path seems fine. I use the path form of 'c/folder1/folder2/nameofthekeyfile'. – kek Oct 07 '20 at 14:39
  • Does your path `path/to/the/key/privatkeyfilename` exist? You should check it again. – Thân LƯƠNG Đình Oct 07 '20 at 14:42
  • 1
    Fixed it. The problem was that when you type the path all the way from,for example, c: drive it should be: '/c/folder1/folder2/keyfilename' and not 'c/folder1/folder2/keyfilename'. Thank you very much :). – kek Oct 07 '20 at 14:56
  • I am glad that you have solved your problem. Could you upvote my answer? – Thân LƯƠNG Đình Oct 07 '20 at 15:12
  • I did. It says that I have not enough reputation for my upvote to be displayed :( – kek Oct 09 '20 at 17:05