Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ssh permission denied when prefixing with ssh protocol

I try to add a ssh key to my GitLab account in order to use it through npm.

I added my key following https://docs.gitlab.com/ee/ssh/.

ssh -T [email protected]

Is working fine and deliver the message Welcome to Gitlab, username.

But ssh -T ssh://[email protected] is not working and give me this error message:

Permission denied (publickey).

And when I run npm install on my node project where I added my node module as a dependency inside the package.json file, it's returning the following error:

npm ERR! Error while executing:
npm ERR! /usr/bin/git ls-remote -h -t ssh://[email protected]/myproject/myproject.git
npm ERR!
npm ERR! Permission denied (publickey).
npm ERR! fatal: Could not read from remote repository.
npm ERR!
npm ERR! Please make sure you have the correct access rights
npm ERR! and the repository exists.
npm ERR!
npm ERR! exited with error code: 128

I added my dependency inside package.json as follow:

"my-project": "[email protected]:myproject/myproject.git",

I'm not comfortable with ssh and key pairing, if anyone could tell me what is wrong with my configuration it will help me a lot, thanks.

like image 614
MHogge Avatar asked Feb 05 '19 09:02

MHogge


People also ask

How do I fix SSH permissions denied?

If you want to use a password to access the SSH server, a solution for fixing the Permission denied error is to enable password login in the sshd_config file. In the file, find the PasswordAuthentication line and make sure it ends with yes . Find the ChallengeResponseAuthentication option and disable it by adding no .

Why do I get permission denied publickey?

Short description. "Permission denied (publickey)" and "Authentication failed, permission denied" errors occur if: You're trying to connect using the wrong user name for your AMI. The file permissions within the operating system are incorrect on the instance.

How do I fix permission denied publickey password keyboard interactive?

Permission denied > (publickey,keyboard-interactive). This should be moved to serverfault. The SOLUTION in my case: Remove spaces around comma separators and everything will work fine.


1 Answers

It's kind of funny to be misled by the following line (talking about myself):

ssh -T ssh://[email protected]

The command doesn't expect actually a protocol prefix, but a hostname prefixed or not by a user name followed by an arobase, as said the manual page:

ssh [-1246AaCfGgKkMNnqsTtVvXxYy] [-b bind_address] [-c cipher_spec] [-D [bind_address:]port] [-E log_file] [-e escape_char] [-F configfile] [-I pkcs11] [-i identity_file] [-J [user@]host[:port]] [-L address] [-l login_name] [-m mac_spec] [-O ctl_cmd] [-o option] [-p port] [-Q query_option] [-R address] [-S ctl_path] [-W host:port] [-w local_tun[:remote_tun]] [user@]hostname [command]

Here, it takes actually ssh://git as a user name. That's why it won't log in since the user name which whom you connect has to be git, and not ssh://git.

like image 165
Amessihel Avatar answered Oct 20 '22 16:10

Amessihel