ssh -T github.com results in ssh could not resolve hostname github - 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.

Related

vscode not connecting to multiple gitlab accounts using their respective ssh keys

So for windows, I see the default ssh client config supposed to be placed at C:\Users\Admin\.ssh\config and I use the same, also I am the Admin user.
I added the following ssh client side config:
PS C:\Users\Admin> type .\.ssh\config
Host gc
HostName gitlab.com
User git
IdentityFile ~/.ssh/company_gitlab
Host gp
HostName gitlab.com
User git
IdentityFile ~/.ssh/gitlab_personal
I tested it from Powershell and it is working for both my company and personal GitLab accounts using their respective ssh keys.
PS C:\Users\Admin> ssh -T git#gc
Enter passphrase for key 'C:\Users\Admin/.ssh/company_gitlab':
Welcome to GitLab, #johnwilson!
PS C:\Users\Admin> ssh -T git#gp
Enter passphrase for key 'C:\Users\Admin/.ssh/gitlab_personal':
Welcome to GitLab, #jwilson!
But when it comes to the vscode, when I try to push or pull changes to the remote repository, the following error shows up for both the company and personal GitLab accounts.
> git push -u gc master
git#gitlab.com: Permission denied (publickey,keyboard-interactive).
fatal: Could not read from remote repository.
> git push -u gp master
git#gitlab.com: Permission denied (publickey,keyboard-interactive).
fatal: Could not read from remote repository.
I tried the suggestion from here as well
PS C:\Users\Admin\ownCloud\Company\GitLab\userlist> git remote add origin git#gc:company/infra_code/userlist.git
PS C:\Users\Admin\ownCloud\Company\GitLab\userlist> git remote -v
origin git#gc:company/infra_code/userlist.git (fetch)
origin git#gc:company/infra_code/userlist.git (push)
PS C:\Users\Admin\ownCloud\Company\GitLab\userlist> git ls-remote origin
Enter passphrase for key 'C:\Users\Admin/.ssh/company_gitlab':
611b36ef47056773c288499cb6974d8671196d78 HEAD
611b36ef47056773c288499cb6974d8671196d78 refs/heads/master
I am confused, so vscode does not pick the default ssh client config C:\Users\Admin\.ssh\config on windows ?.
Or am I missing something?.
Check the remote URL associated with the remote named 'gc'
cd C:\path\to\gc\repo
git remote -v
If the URL starts with git#gitlab.com:..., it won't use the ~/.ssh/config file, and its gc entry.
Change it with the proper URL
git remote set-url gc gc:<me>/<myrepo>
Then VSCode will pick up the right entry, assuming is is running as User Admin.
The OP JohnW confirms in the discussion:
I added an SSH key without a passphrase, which is working for vscode. So this is bug with VSCode cannot connect with ssh key with passphrase?
You need to make sure ssh-agent is activated first.
See "Auto-launching ssh-agent on Git for Windows"
Once the SSH agent is launched (and your private SSH keys passphrase cached in it), you can launch VSCode. It should work then.

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

Is it required to regenerate SSH key for new EC2 instance when cloning a github repo via SSH URL?

As discussed here and here, it seems that connecting to github repo via SSH protocol requires a newly generated key.
I just tried today on my EC2 instance and failed to git pull my github repo; i.e. reusing a key pair generated on another EC2 instance is not working.
So I want to raise the issue here so that we all can confirm this - Is it required to regenerate ssh key for new EC2 instance when git clone a github repo?
p.s.
What I have done and failed on Ubuntu Server 14.04 are as below.
ssh key files
cloned key in ~/.ssh
public key registered in github
calling git
run ssh -vT git#github.com
run git clone git#github.com:MY_USER/MY_PROJECT.git MY_FOLDER get Public key denied error
So I want to raise the issue here so that we all can confirm this - Is it required to regenerate ssh key for new EC2 instance when git clone a github repo?
in brief
No need for re-generated key.
details
Reusing the key from different instance SHOULD WORK too, but you need to place it to the proper location with the correct permissions.
You may try
Restart your SSH connection to the EC2.
Specify the private key via GIT_SSH_COMMAND prefix
sudo GIT_SSH_COMMAND="ssh -i ~/.ssh/YOUR_PRIVATE_KEY" git clone git#github.com:USER/PROJECT.git YOUR_LOCAL_DIR
p.s.
You can clone over HTTPS without any SSH key.

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

Cannot connect to GitHub through SSH: host not known

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