two ssh keys for two different repositories are not working in config - github

I just added a second ssh key in my .ssh folder on my mac to access the repo of my client.
The second repo I want to access is github.
I prepared my config file like:
Host github.com
IdentyFile ~/.ssh/id_github
Host xyz.*
IdentyFile ~/.ssh/id_xyz
Now I am able to access my clients repository, but not github anymore.
I also tried it with hostName entry but it did not work.
When I try ssh -vvv git#github.com I receive
OpenSSH_8.6p1, LibreSSL 2.8.3
debug1: Reading configuration data /Users/name/.ssh/config
debug1: /Users/name/.ssh/config line 1: Applying options for github.com
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 21: include /etc/ssh/ssh_config.d/* matched no files
debug1: /etc/ssh/ssh_config line 54: Applying options for *
debug3: expanded UserKnownHostsFile '~/.ssh/known_hosts' -> '/Users/name/.ssh/known_hosts'
debug3: expanded UserKnownHostsFile '~/.ssh/known_hosts2' -> '/Users/name/.ssh/known_hosts2'
debug1: Authenticator provider $SSH_SK_PROVIDER did not resolve; disabling
debug1: Connecting to github.com port 22.
debug1: Connection established.
debug1: identity file /Users/name/.ssh/id_ed25519 type 3
debug1: identity file /Users/name/.ssh/id_ed25519-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_8.6
But when I pull, nothing happen.
Can anybody help me?
Kind regards, nullpointer

Your configuration has a typo. The configuration option is IdentityFile, and it needs to be used in conjunction with IdentitiesOnly.
How to configure this correctly can be seen in the Git FAQ.

Well, I fixed it. After I found out that ssh -vT git#github.com established a connection and ssh git#github.com did not, I removed my vpn from my client and all worked fine. The problem was a running vpn.
Thanks

Related

SSH connection to Github via port 443

I have my github keys working on port 22, a simple test like
ssh -T git#github.com
Returns,
"You've successfully authenticated, but GitHub does not provide shell
access"
However, when I try the same with port 443, which I believe it should work,
ssh -vvvT git#github.com -p 443
I get,
OpenSSH_for_Windows_8.1p1, LibreSSL 3.0.2
debug1: Reading configuration data ~/.ssh/config
debug3: Failed to open file:C:/ProgramData/ssh/ssh_config error:2
debug2: resolving "github.com" port 443
debug2: ssh_connect_direct
debug1: Connecting to github.com [140.82.112.3] port 443.
debug1: Connection established.
debug1: identity file ~/.ssh/id_rsa type 0
debug3: Failed to open ~/.ssh/id_rsa-cert error:2
debug3: Failed to open ~/.ssh/id_rsa-cert.pub error:2
debug1: identity file ~/.ssh/id_rsa-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_for_Windows_8.1
kex_exchange_identification: Connection closed by remote host
I have tried many forums and online searches, but it hasn't resolved. Am I missing something? Thanks.
In past I have successfully used ssh over 443 for github pulls/pushes. Github has documention on how to use 443 for ssh here: https://docs.github.com/en/authentication/troubleshooting-ssh/using-ssh-over-the-https-port
The documentation that you linked to indicates that you can connect to a hostname of "ssh.github.com" on port 443:
$ ssh -T -p 443 git#ssh.github.com
^^^^^^^^^^^^^^-- Note "ssh.github.com"
According to your debug output, you're connecting to "github.com", not "ssh.github.com":
ssh -T git#github.com
...
debug1: Connecting to github.com [140.82.112.3] port 443.
^^^^^^^^^^-- Note no "ssh"
The second part of the page describes how you can configure your ssh client so that when you tell it to connect to "github.com", it will connect to "ssh.github.com" instead. As it describes, you could add the following four lines to the end of your local .ssh/config file:
Host github.com
Hostname ssh.github.com
Port 443
User git
Once you've done that, running a command like ssh -T git#github.com would actually connect to the hostname "ssh.github.com"

SSH login not working on centos due to bad sshd configuration

I was trying to configure SFTP on Centos server. I edited /etc/ssh/sshd_config file and restarted service. There was an error on Chroot line. After a while connection broke with server and from then, no one is ever able to login to server. Obviously, unable to correct sshd configuration as unable to login to server.
I have root details. Plesk is configured to the server to manage domains. Still not able to do much.
Below is error log when trying for ssh login:
debug1: Authentication succeeded (publickey).
Authenticated to *.*.*.* ([*.*.*.*]:*).
debug1: channel 0: new [client-session]
debug1: Requesting no-more-sessions#openssh.com
debug1: Entering interactive session.
debug1: pledge: network
debug1: channel 0: free: client-session, nchannels 1
Connection to *.*.*.* closed by remote host.
Connection to *.*.*.* closed.
Transferred: sent 3412, received 2164 bytes, in 0.1 seconds
Bytes per second: sent 54190.6, received 34369.4
debug1: Exit status -1
If your entire SSH config is just messed up, you may just want to uninstall it and then reinstall it.
From root or using sudo:
Erase:
# chkconfig sshd off
# service sshd stop
# yum erase openssh-server
Install:
# yum –y install openssh-server openssh-clients
# systemctl start sshd
That's a really broad solution, if you have more details I may be able to help you further.

SSH: debug1: Connecting to github.com [192.30.253.112] port 22

Why, when debugging SSH, do I get a private IP being used for github.com?
E.g. using ssh -T
debug1: Connecting to github.com [192.30.253.112] port 22.
That's not a private IP address. The only private IPs in the 192.0.0.0/8 block have a second byte of 168 (i.e., 192.168.0.0/16), not 30.

Can't establish Postgres pgAdmin SSH tunnel on Ubuntu

I have a droplet on DigitalCloud with Ubuntu 14.04 and PostgreSQL 9.3. On local machine i have the same configuration.
My ssh connection is working so there is no problem with it. It must be somewhere in my Postgres connection or environment settings.
So what i have already done on the server is:
changed the listening port in /etc/ssh/sshd_config
Port 4321
enabled remote connections in /etc/postgresql/9.3/main/pg_hba.conf
host all all 0.0.0.0/0 md5
added listening addresses in /etc/postgresql/9.3/main/postgresql.conf
listen_addresses = '*'
And here is my local connection settings:
Here is my Properties tab screen
Here is my SSH Tunnel tab screen
I use just the same (and only) id_rsa.pub file which i used to establish my ssh connection before. Which is working. And this is an error that i get upon trying to connect:
SSH error: Authentication by identify file failed with error code -16
[Unable to extract public key from private key file: Wrong passphrase
or invalid/unrecognized private key file format]
My passphrase was set to empty.
If i try to connect without SSH tunnel there is another error:
Error connecting to the server: SSL error: unknown protocol expected
authentication request from server, but received S
I'm a complete newbie to it and I may have missed something important. So tell me if you want me to provide any other info on this matter.
EDIT 1:
If i use correct id_rsa file (without pub) then i get this same error:
Error connecting to the server: SSL error: unknown protocol expected
authentication request from server, but received S
I use just the same (and only) id_rsa.pub file
The first issue is that this is the wrong file. See if you have a file in the same place named "id_rsa" without the ".pub" extension. That is the file you should use as the identity file.
RSA ssh keys come in two files: "id_rsa" contains the private key, while "id_rsa.pub" contains the public key. id_rsa.pub is installed onto the server that you are connecting to, while id_rsa is used by the client that is making the connection to the server.
(Key files can be named something other than "id_rsa", of course. The point is that the private key is in foobar, while the public key is in foobar.pub.)
If you don't have an id_rsa file, then you should generate a new key and keep both files this time.
The second issue is that you have the wrong port on the Properties tab. The port number on the properties tab is the port that the PG server is running on. You should set this to 5432 or whatever port your server is actually listening on. It seems you should also set the "host" on the properties tab to "localhost", but I don't know if this is required.
Error connecting to the server: SSL error: unknown protocol expected authentication request from server, but received S
What is happening now is that your tunneled PG connection is going to port 4321 on the remote host, which is the SSH server. It happens that the first thing an SSH server sends to a new client is a version string, which looks like "SSH-2.0-OpenSSH_6.9" I don't know the PG protocol, but apparently your client reads the "S" in the SSH string and immediately knows it's not connected to a PG server.

ssh forwardagent with 2 idenities

I'm trying to push changes to a clients github account from their server using ForwardingAgent, but my id_rsa_corevm identity isn't being forwarded.
In my ~/.ssh/config file I have this
Host corevm
Hostname 192.168.56.101
User user1
IdentityFile ~/.ssh/id_rsa_corevm
ForwardAgent yes
macbook-pro:.ssh macuser$ ssh-add -l
######## /Users/macuser/.ssh/id_rsa (RSA)
######## /Users/macuser/.ssh/id_rsa_corevm (RSA)
When I ssh into their server and test the ssh connection to github, I see my id_rsa_corevm identity but still can't connect to the clients github account.
[user1#corevm ~]$ ssh -t -vv git#github.com
debug2: key: /Users/macuser/.ssh/id_rsa (#####)
debug2: key: /Users/macuser/.ssh/id_rsa_corevm (######)
I only see one 'Offering public key' and not my id_rsa_corevm.
debug1: Offering public key: /Users/macuser/.ssh/id_rsa
Hi githubuser! You've successfully authenticated, but GitHub does not provide shell access.
The success message means my default id_rsa file IS being forwarded and I can connect to my own github account.
Then I try to push a change to the clients github, I get permission denied.
[user1#corevm test]$ git push origin master
ERROR: Permission to clientgithubuser/test.git denied to githubuser.
fatal: The remote end hung up unexpectedly
I would prefer to just add my id_rsa.pub to my clients github account, but apparently github does not allow sharing of keys.
Any ideas?