Cannot connect to GitHub through SSH: host not known - github

What is the format for SSH URLs in GitHub?
I'm trying with:
ssh git#github.com:Ziiweb/home
but I get
ssh: Could not resolve hostname github.com:Ziiweb/home: Name or service not known

Github is not accessible by SSH, this is protocol used by git for authentication by SSH Keys, so the command is
git clone git#github.com:Ziiweb/home
From GitHub docs Set Up Git:
If you use the SSH repository URL (...), SSH keys are used for authentication.
More: Generating SSH Keys

Related

GitBucket SSH Based Authentication

I configured the SSH based authentication as below
Created a public key on my UNIX server
Added the public key on my Bitbucket repository with reading and write privileges (also tried it at account level)
changed the URL from https to SSH at bitbucket and Unix server
verified the URL using and it is displaying SSH URL only
Then Tried to push, but I am getting the below error:
Permission denied (public key). fatal: Could not read from remote repository.
Please make sure you have the correct access rights and the repository exists.
I have read and write access to the repository
push command
git push -u origin master
Any idea?
You should try:
GIT_SSH_COMMAND="ssh -Tv" git push
You will see what Git is using as an SSH key, and if there are any error messages.
If the error persists, it is possible there is something preventing SSH to operate properly (as in here, when not connected to a VPN)
Using HTTPS, of course, is a workaround:
git remote set-url origin https://git#bitbucket.XXX.com/XXX.com/XXX.git
After discussion, the missing step was to add the private key to the ssh-agent
ssh-add OEDQ_BIT added the private key

ssh -T github.com results in ssh could not resolve hostname github

I am trying to clone my public Git repository using Putty instead of Git Bash. I am doing this over ssh instead of Https(which is the requirement). The Linux machine which i am accessing through putty has IBM OS(Linux on z/os). I have created the rsa keys and added same on Github. While trying to clone my repository , i am getting error as
'ssh-rsa: /usr/lpp/Files/.ssh/id_rsa.pub 1: FSUM7351 not found
fatal: Could not read from remote repository.' although the public key is present.
IBMUSER:/Z21S/usr/lpp/Files/.ssh: >ls
id_rsa id_rsa.pub
When i am trying to issue command ssh -T github.com, i am getting error as ssh could not resolve hostname github
Please suggest.

Private Github Repositories with Envoy

Anybody has any problems deploying with Laravel's envoy when using private Github repos?
When manually cloning my repo from the production server, the ssh key seems to be accessible but when using Envoy, I always get a "Permission denied (publickey) error.
Thanks
It is probably because the ssh key on your remote server requires a password.
If you change the Envoy.blade.php to perform some other task you should be able to establish whether you are connecting to your remote correctly.
#servers(['web' => 'user#domain.com'])
#task('deploy')
cd /path/to/site
git status
#endtask
Should return something like:
[user#domain.com]: On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working directory clean
If you are connecting using a Mac or Linux you probably don't have to enter your password because your terminal is using ssh-agent which silently handles your authentication.
Wikipedia article on ssh-agent
When connecting over ssh, ssh-agent isn't running and the script is being prompted for a password which is where it is failing.
To get around this you could to generate a new key on the remote machine that doesn't use a password.
If you want to restrict the ssh key to a single repository on GitHub have a look at deploy keys
You need to pass the -A (as per the man page it - Enables forwarding of the authentication agent connection. This can also be specified on a per-host basis in a configuration file) in you ssh string.
You will also need add your ssh key for agent forwarding (on the machine which can access the git remote which I assume be your localhost)
ssh-add -K ~/.ssh/your_private_key
Something like this
#servers(['web' => '-A user#domain.com'])
#task('deploy')
cd /path/to/site
git status
#endtask
Git remote commands should now work.

How to perform ssh to gitlab

I am trying to setup the gitlab for my project. I have my ssh key setup in gitlab and I wanted to ssh to my project. I got the ssh link from gitlab
git#git.calculator.com:calculator/engineering.git
However, when I tried to ssh git#git.calculator.com:calculator/engineering.git in my terminal I got
ssh: Could not resolve hostname git#git.calculator.com:calculator/engineering.git: nodename nor servname provided, or not known
I got the ssh link from gitlab and I am not sure why can't I ssh to it. Can anyone help me about this issue? Thanks a lot!
You don't ssh to a full ssh url.
You can check ssh git#git.calculator.com to see if you have (non-interactive probably) ssh access.
But the ssh url mention by GitLab is for cloning (as I mentioned, for instance, in "Can't clone gitlab's repo via ssh, via http - OK"):
git clone git#git.calculator.com:calculator/engineering.git
cd engineering
git log

Authentication Failure on Github even after adding SSH key

I get fatal:Authenication Failure when I try to push code to my repo. I've added the public key on my github account as well. When I do :
ssh -i git#github.com
I get
Hi amangupta052! You've successfully authenticated, but GitHub does not provide shell access.
Can anyone help?
Thanks
That depends on the remote url you have used.
If git remote -v returns:
https://github.com/username/reponame
Then your ssh setup won't matter. But this would work:
ssh://git#github.com:username/reponame
Another cause is linked to your private key: if it is pass-phrase protected, with a special character in it, that usually don't work well.
See here for other ssh causes of failure.
To replace your remote named origin, use git remote commands:
git remote set-url origin ssh://git#github.com:username/reponame
(as explained in the GitHub help page about changing the rmeote url)
If you see::
ssh: Could not resolve hostname github.com:amangupta052:
Name or service not known
fatal: The remote end hung up unexpectedly
Try the non-scp ssh syntax:
git remote set-url origin ssh://git#github.com/username/reponame
(note the '/' instead of the ':' after github.com)
Maybe this would have worked, as commented in this blog post:
git remote set-url origin git#github.com:username/reponame
(scp-like syntax, but without the ssh:// prefix)
As I mention here, an scp syntax usually means an ~/.ssh/config file to work properly.