fatal: Authentication failed when trying to clone GitLab project even though "ssh -i" command prints "Welcome to GitLab, [username]" - ssh

I cannot clone the project although
ssh -T git#gitlab.com
shows what I want: Welcome to GitLab, #vagnerwentz!.
The error during cloning:
Cloning into 'jobfygo'...
Username for 'https://gitlab.com': vagnerwentz
Password for 'https://vagnerwentz#gitlab.com':
remote: HTTP Basic: Access denied
fatal: Authentication failed for 'https://gitlab.com/jobfy/backend/jobfygo.git/'

I resolved changing the SSH Key to RSA Key.

First, you are cloning with an HTTPS URL, which means all your SSH settings is for naught.
Second, regarding HTTPS, double-check if you have 2FA activated, because if you do, your password would actually be a PAT (Personal Access Token)
Third, if you do want to use SSH, then use the SSH URL:
git#gitlab.com:jobfy/backend/jobfygo.git
By default, such an url would use the default private SSH key ~/.ssh/id_rsa.
So if you have a key with another name, you would need to:
either rename it to id_rsa
specify it directly ssh -i /path/to/second/private/key
use a ~/.ssh/config file

Related

github deploy key not working for my cyberpanel user

I have a site on CyberPanel, user "thows3051" and want to use git to manage my site. But when I try ssh -T git#github.com I get git#github.com: Permission denied (publickey)..
If I ssh into the server on that user ssh thows3051#mysite.com, into the .ssh directory, there is a thows3051.pub file which I copied the contents into the repo on github under "deploy keys".
EDIT
Was able to explicitly use the correct key with ssh -i ~/.ssh/thows3051 -T git#github.com which shows You've successfully authenticated....
So my question is why isn't the user using the right ssh key?
Thanks in advance
Was able to fix it. I'm not sure what key was being used, if any?
But if you create a file in ~/.ssh/config, you can put the following inside:
IdentityFile ~/.ssh/thows3051
And it will use that key.
Note that you can set specific keys for certain hosts, for example:
Host github.com
IdentityFile ~/.ssh/github.key

Cloning private repository with cPanel SSH key throw error "permission denied"

I accessed my cPanel server via SSH with help of username#host and password.
Generated SSH key (RSA) and added it to my GitLab account.
When I tried cloning it shows me an error, fatal: Could not read from remote repository
I think this is an error from the cPanel side but not able to resolve, help me out
From your CPanel server session, check if your generated key works with:
ssh -Tv git#gitlab.com
If you don't see a Welcome to GitLab, #username! at the end, that means the key is not properly registered.

Microsoft TFS ssh cloning fails

I am trying to clone a repo from a project on my Team Foundation Server domain. I have created an SSH key under my profile security. However after accepting the repo's key I am still requested to sign in with a password and the authentication fails:
git clone ssh://mydomain#mydomain.visualstudio.com:22/Project/_git/project-repo
Cloning into 'project-repo'...
mydomain#mydomain.visualstudio.com's password:
Permission denied, please try again.
mydomain#mydomain.visualstudio.com's password:
Permission denied, please try again.
mydomain#mydomain.visualstudio.com's password:
Permission denied (password,publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
I have tried both my visualstudio.com password and SHH key password none of which work.But Why is it asking me for a password?
The prerequisite to use ssh for VSTS as below:
Generate ssh key. In git bash, use ssh-kengen in git bash -> select path to save the key -> enter passphrase (if you don’t want passphrase, press enter direcly).
Add the content of .ssh/id_rsa.pub file in KeyData in VSTS SSH public keys (profile -> security).
For your situation, it seems the conent of .ssh/id_rsa.pub is not same with VSTS SSH public keys. So you'd better do step1 and setp2 above and ten clone again with ssh protocol.
The way I resolved this was by deleting and recreating my id_rsa.pub without a password.
The default authentication mode when using SSH is the private key. Whenever that fails for some reason, the ssh-agent falls back to username and password based authentication.
There are several reasons why the default key based authentication might have failed. Following are the most common cases :
a) The ssh-agent cannot find the default private key file which is id_rsa, and no other key path is specified explicitly.
b) The public key stored in the server is incorrect.
c) The path you're trying to clone is incorrect.
In any case, to troubleshoot the issue first of all execute the git clone command with verbose logging with the command :
GIT_TRACE=1 GIT_SSH_COMMAND="ssh -vvv" git clone ssh://pathToYourRepo
You can go through each step in the log to get an intuition of what the issue might be.
Troubleshooting in case of (a)
Make sure you have the default key name id_rsa in the .ssh directory. You might have specified some different keyname when generating the key with ssh-keygen command or maybe there isn't any key at all).
In case you want to specify a different key for authentication, use the following command :
ssh-agent bash -c 'ssh-add ~/.ssh/anotherKey; git clone ssh://pathToYourRepo'
Troubleshooting in case of (b)
Make sure there aren't extra white spaces when storing the public key in the server.
Troubleshooting in case of (c)
Make sure you aren't trying to clone with the https version of the repository path.

ssh authentication fails after ssh-agent terminates

Backstory: currently running Arch Linux and attempting to authenticate into Github using SSH keys. I have openssh 7.1p1-1 installed as well as git 2.6.4-1.
Problem: After the ssh-agent terminates (system reboot or shell closure), I get the "Permission Denied (publickey)" message when attempting to connect to git using:
ssh -vT git#github.com
Any ideas as to why my identity does not persist? Do I have to add anything special to the ~/.ssh/config or /etc/ssh/ssh_config files?
Thank you for any help you can provide.
After ssh-agent is gone, ssh is no longer aware that id_github exists, so it never tries authenticating with that key. If you want to force ssh to always use that key for github.com, you can add this to ~/.ssh/config:
Host github.com
IdentityFile ~/.ssh/id_github
User git # Handy addition so you can skip the username part in Github URLs

Mercurial: How to clone using SSH and .ppk file?

hg clone ssh://denis#medsecop.com//var/www/vhosts/medsecop.com/stage/symphony
returns
remote: Permission denied (publickey).
abort: no suitable response from remote hg!
I have the .ppk file but I don't know how to add options to the ssh command above to use (it says "hg clone doesn't take more arguments")
-i /path/to/keys.ppk
I connect to SSH with this:
sudo ssh -v denis#medsecop.com -i /home/denis/Desktop/MedSec/my-openssh-key
Any ideas?
If you tag question with putty tag, I suppose, you use Windows at your side (and some Win-specific details I'll mention later)?
I don't know how to add options to the ssh command above to use
Well, for any ssh-powered repositories you must to define used ssh-client in (global, user- or repository-specific) config file. For key-based authorization you can define private-key file as parameter of used command or use special additional tool (ssh-agent in *Nix or pageant in Win or...)
Sample
Windows-box with Mercurial (TortoiseHG), full Putty, without Cygwin
Key-based authorization for ssh-repositories: Plink + Pageant
Global mercurial.ini part
[ui]
merge = ...
username = ...
ssh = "PATH\TO\TortoisePlink.exe"
Also Pageant is running and (putty-type) private keys for published public keys loaded into it
When I connect to any ssh-repo, authorization happens automagically
Pageant-less version may include
-i KEYFILE option for TortoisePlink at the repository level - in the .hg\hgrc
--load SESSION option for TortoisePlink (same location as above) for using previously created Putty's session, which have all needed authorization predefined
I solved it by adding the public key
ssh-add file.ppk