Xcode - Authentication failed error when adding repository with SSH auth - xcode

I am trying to add repository via Xcode > Settings > Accounts and I am stuck on the proper address. Address of our repo is quite simple: my.domain.com:port/project-name. Authentication via SSH Keys. Could someone help me to understand what's going on here? See screenshot below.
By the way running git clone git+ssh://git#my.domain.com:port/project-name works fine.
EDIT
Running git clone without git+ssh//
git clone git#my.domain.cz:2222/project-name
or
git clone git#my.domain.cz:22/project-name
is giving me same error:
ssh: connect to host my.domain.cz port 22: Connection refused
fatal: Could not read from remote repository
Please make sure you have the correct access rights and the repository exists.

Xcode accepts just ssh://git#my.domain.cz:2222/project-name.
The git protocol is somehow redundant in this case. Raw git tools don't have a problem with it, but Xcode does not like it for some reason.

It always fails for me when I use existing ssh keys.
I created a new ssh key pair through Xcode and uploaded the public key to the git server (in my case, Phabricator), and it works.

Related

Git configuration on windows for ssh access to Github

I have a Github account with multiple projects.
I have cloned these projects to my windows 10 computer using ssh key.
some time later, it appear my ssh keys were compromise so i delete my ssh on Github and locally, then regenerate new ones :
4096 bits
rsa2
saved the pub as ~/.ssh/git_id_rsa.pub
add the pub key to my Github ssh keys
saved the priv as ~/.ssh/git/git_id_rsa.ppk
converted to Openssh format as ~/.ssh/git_id_rsa
the fact is I want different ssh keys for my different web tools (one for GitHub, one for DigitalOcean, one for OVH cloud, etc...) and I want to specify witch key to use when connecting to each host. thats why I change the default name for the ssh generated with PuttyGen (and converted with the same).
I don't have passphrase on the git_id_rsa.ppk (nor git_id_rsa) keys, as it seems that GitHub dont like them (saw long time ago).
I've configure my (projecytdir)/.git/config like bellow :
[remote "origin"]
url = git#github.com:hdGuild/JenkinsServerOnDO.git
fetch = +refs/heads/*:refs/remotes/origin/*
identityfile= ~/.ssh/git_id_rsa
But when I try a Git Pull, I've got the following error :
git#github.com: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Following the following answers I've created the ~/.ssh/config file with the following (using OpenSSH key for GitHub), and it works :
Host github.com
IdentityFile ~/.ssh/git_id_rsa
The fact is that if I need the ~/.ssh/config file, why would I need to configure my local git with (projecytdir)/.git/config as I describe it above ?
I would like to configure my local git to use the right ssh key for Github, without having to explain it in my ~/.ssh/config file.
I'm sure it is (again) a configuration problem and I miss something somewhere, but I can't find where.
Please help :)
thank-you
Okay,
As previously, I answer my own question :D
After some more research, I found this post that explain how to specify in Git local config file, the ssh key to use for git sh connection.
The command is simply, in the above explained case, the following while in project directory :
git config core.sshCommand "ssh -i ~/.ssh/git_id_rsa -F /dev/null"
This way, the git_id-rsa will be used by git for ssh connections on this particular project (as it is a local configuration).
Thank-you for reading.

Pushing commits to an SSH-cloned repo via VS Code on WSL returns "Host key verification failed" - it's ok on HTTPS

I'm on a Windows 10 machine and I have both Git Bash and Ubuntu for Windows Subsystem for Linux (WSL) installed. When I use GitHub's official desktop app to clone a repo via HTTPS everything works fine and I can push my commits via Visual Studio Code with no problems whatsoever. I then try to clone a repo via SSH with Hyper (WSL Bash) and get this:
The authenticity of host 'domain.com (a.b.c.d)' can't be established.
RSA key fingerprint is XX:XX:...:XX.
Are you sure you want to continue connecting (yes/no)?
After answering yes and openning that repo in VS Code and try to push my new changes to GitHub, I get this error:
Git: Host key verification failed.
And this is what I get as Git Log in Output:
Host key verification failed.
fatal: Could not read from remote repository.
I have set up my SSH key on WSL using this method and I didn't set up any passphrase. I tried this on my brother's PC which is exactly set up like mine and it worked just fine. I would appreciate any help!
UPDATE: I typed ssh -T git#github.com in Hyper and got this as an answer: You've successfully authenticated, but GitHub does not provide shell access.
P.S. I'm a newbie in programming and stackoverflow, so please be concise and give me step by step instructions. The more you use technical terms, the more I'll probably get lost!
Try first, for that new push, to do it in command line:
cd c:\path\to\local\repo
git status
git log
git remote -v
git push -u origin master
Make sure that:
git status is clean (no pending changes)
git log shows you at least one commit
git remote -v shows you as origin the URL of your remote GitHub repository
(as an SSH URL git#github.com:<you>/<yourRepo>)
Then push, and go back to VSCode.
Should be faster than the other solution:
In vscode open a new terminal of type "Command Prompt"
Run: git push and accept the new key when prompted.
This will store the remote key for future use.

Visual Studio - Git clone fails over SSH, but works over HTTPS

I am using a fresh install of Visual Studio 2017 (15.8.1), and Git tools.
When I try to clone an existing GitHub repository, either by using the commandline tools, or by using git tools, I receive the following error message:
git#github.com: Permission denied (publickey).
fatal: Could not read from remote repository.
I believe this error is caused by SSH and I cannot seem to make git use HTTPS. Thanks in advance.
If you are using 2-factor authentication at GitHub
You must either do one of the following:
Use the SSH link, add an SSH key to your GitHub account and load it using the SSH agent in Windows, this may be done using Putty.
Generate a personal access token, and use the HTTPS link. Use your GitHub username as the username, but use the generated access token as your password.
If you want to clone any repository using https
Simply clone it using the HTTPS-link instead of the SSH link. You can find both links here, by clicking on Use SSH, you can switch to the SSH link:
In my case, I had to delete ~/.ssh/known_hosts file, so that a new one will be made next time you access git over ssh.

How to push to bitbucket using intellij

I have created a project in bitbucket and trying to push code using intellij git. When I created the project bitbucket gave me commands to run within git. Here are the commands I ran and the error I got:
git remote add origin ssh://git#bitbucket.org/[username]/[repo]
git push -u origin master
This looks strange because how is this command suppose to authenticate me? Now here is error I got.
Permission denied (publickey). fatal: Could not read from remote
repository.
Please make sure you have the correct access rights and the repository
exists.
Any ideas?
That is because you are creating your project via ssh and for that you need to create and registrate SSH keys.
Create ssh key
If you don't want that, create your project only via https
Do you have the ssh key added to your computer?
If you're using oSX El Capitan or newer you'll need to add these every time you restart. osx ssh keys
How to add ssh keys

Pushing a branch to a remote server fails

I have a project which uses Git on a remote server. I installed SourceTree for Mac to manage it. I also have a .ssh folder with the private in the root directory where I keep all my projects and the public key is in the server.
I was able to clone the project successfully and even commit+push it back with no problem. Then I ceated a branch in my local repo, added a new file and tried commit+push it. It was committed but the pushing failed with the following error message.
Pushing to git#gitserver:gitbtest
ssh: Could not resolve hostname gitserver: nodename nor servname provided, or not known
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
I'm not sure why this is happening. Is there a way to set SSH keys in SourceTree for Mac? I can't seem to find any option to do so.
Any help to resolve this would be great.
Thank you!
An url like git#gitserver:gitbtest can only work if one have an ssh config file in order to resolve the name gitserver:
$HOME/.ssh/config
Host gitserver
Hostname xxx.xxx.xxx.xxx # IP or full name for gitserver
User git
IdentityFile ~/.ssh/id_rsa
Actually, with such a file, you don't even have to specify the user:
git remote set-url origin gitserver:gitbtest
(You can see an example of that ~/.ssh/config file used in "git public key for more repositories")

Resources