1

While adding an ssh-key in gitlab using git bash, I am getting the error:

"Saving key 'keyname' failed: Permission Denied"

. What shall I do?

This is the input-

$ ssh-keygen -t rsa -C "name@email.com"
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/UserName/.ssh/id_rsa): fileName
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Saving key "fileName" failed: Permission denied

PS- Following things I have already tried-

  1. Setting the environment variable
  2. I have used cmd for inserting the same command, but was getting the following error- "ssh-keygen is not recognized as an internal or external command, operable program or batch file"
  3. Changing the current directory to

C:\Program Files\Git\bin

This is the path that I have set (as suggested from another SO question)-

C:\Program Files\Git\bin\ssh-keygen.exe

This was the SO question that I referred. Thanks in advance.

Community
  • 1
  • 1
HardikT
  • 735
  • 1
  • 8
  • 24

1 Answers1

0

I have used cmd for inserting the same command,

That is a valid approach

but was getting the following error- "ssh-keygen is not recognized as an internal or external command, operable program or batch file"

Simply add to your %PATH% <path\to\git>\usr\bin.
And don't use the msi setup, simply unzip the latest release anywhere you want:
PortableGit-2.9.0-64-bit.7z.exe (self-extracting archive).

For instance:

set PATH=%PATH%;C:\git\PortableGit-2.9.0-64-bit.7z.exe\usr\bin

Make sure you are in %USERPPROFILE%: ssh-keygen will generate those keys in %USERPPROFILE%\.ssh.

The OP Trivedi confirms it is working with:

I didn't give a filename; i.e. just pressed 'enter' when asked for filename and passphrase!

That is the easiest way: default id_rsa(.pub) named keys, with no passphrase.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Well, it's a bit funny and weird, but I didn't give a filename; i.e. just pressed 'enter' when asked for filename and passphrase! – HardikT Jul 06 '16 at 10:50
  • @Trivedi I have edited the answer to include your comment and explain what not entering a filename and password means. – VonC Jul 06 '16 at 10:54
  • @Trivedi That is the idea indeed :) – VonC Jul 06 '16 at 11:04