I can't connect via SSH

Good afternoon , everyone .
Happy New Year 2022!

I’m a newbie. I ask for help.
I followed all the instructions for creating an SSH key using git bash id_ed25519.pub when checking the connection, I get an error. Below is the output of git bash.

user@user-laptop MINGW64 ~
$ ssh -Tvvv git@gitlab.com://IgorKu/date_recovery.git
OpenSSH_8.8p1, OpenSSL 1.1.1l 24 Aug 2021
debug1: Reading configuration data /etc/ssh/ssh_config
debug2: resolve_addr: could not resolve name gitlab.com://IgorKu/date_recovery.git as address: Name or service not known
debug1: resolve_canonicalize: hostname gitlab.com://IgorKu/date_recovery.git is an unrecognised address
debug3: expanded UserKnownHostsFile ‘~/.ssh/known_hosts’ → ‘/c/Users/user/.ssh/known_hosts’
debug3: expanded UserKnownHostsFile ‘~/.ssh/known_hosts2’ → ‘/c/Users/user/.ssh/known_hosts2’
debug2: resolving “gitlab.com://IgorKu/date_recovery.git” port 22
debug3: resolve_host: lookup gitlab.com://IgorKu/date_recovery.git:22
ssh: Could not resolve hostname gitlab.com://IgorKu/date_recovery.git: Name or service not known

ssh -T is only for testing, and you do it like this:

ssh -T git@gitlab.com

nothing else. That is why it fails as you do not provide the repo part.

I’ll put everything in order
I go to docs.gitlab.com in GitLab and SSH keys.
Git bash-
user@user-laptop MINGW64 ~/.ssh
$ ssh-keygen -t ed25519 -C " "
Generating public/private ed25519 key pair.
Enter file in which to save the key (/c/Users/user/.ssh/id_ed25519):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /c/Users/user/.ssh/id_ed25519
Your public key has been saved in /c/Users/user/.ssh/id_ed25519.pub
The key fingerprint is:
SHA256:QlOjT26FkabSxbtJIxepcE5FJDNXrXCYa7PEXL+6OB0
The key’s randomart image is:
±-[ED25519 256]–+
| +=O*… |
| . oB@+o . |
| +BoB.o |
| …
=%… . |
| …S . |
| o+ E . |
| . o |
| …o |
| … |
±—[SHA256]-----+

user@user-laptop MINGW64 ~/.ssh
$

user@user-laptop MINGW64 ~/.ssh
$ eval $(ssh-agent -s)
Agent pid 2373

user@user-laptop MINGW64 ~/.ssh
$ ssh-add ~/.ssh/id_ed25519
Identity added: /c/Users/user/.ssh/id_ed25519 ( )

user@user-laptop MINGW64 ~/.ssh
$ ls
id_ed25519 id_ed25519.pub

user@user-laptop MINGW64 ~/.ssh
$ touch config

user@user-laptop MINGW64 ~/.ssh
$ ls
config id_ed25519 id_ed25519.pub

user@user-laptop MINGW64 ~/.ssh
$ nano config

user@user-laptop MINGW64 ~/.ssh
$ cat config

GitLab.com

Host gitlab.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/gitlab_com_rsa

Private GitLab instance

Host gitlab.company.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/example_com_rsa

user@user-laptop MINGW64 ~/.ssh
$ cat id_ed25519.pub
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKoLgS59Sq/

user@user-laptop MINGW64 ~/.ssh
$ ssh -T git@gitlab.example.com
ssh: Could not resolve hostname gitlab.example.com: Name or service not known

user@user-laptop MINGW64 ~/.ssh
$ ssh -T git@gitlab.com:IgorKu/date_recovery.git
ssh: Could not resolve hostname gitlab.com:IgorKu/date_recovery.git: Name or service not known
user@user-laptop MINGW64 ~/.ssh
$ ssh -Tvvv git@gitlab.example.com
OpenSSH_8.8p1, OpenSSL 1.1.1l 24 Aug 2021
debug1: Reading configuration data /c/Users/user/.ssh/config
debug1: Reading configuration data /etc/ssh/ssh_config
debug3: expanded UserKnownHostsFile ‘~/.ssh/known_hosts’ → ‘/c/Users/user/.ssh/known_hosts’
debug3: expanded UserKnownHostsFile ‘~/.ssh/known_hosts2’ → ‘/c/Users/user/.ssh/known_hosts2’
debug2: resolving “gitlab.example.com” port 22
debug3: resolve_host: lookup gitlab.example.com:22
ssh: Could not resolve hostname gitlab.example.com: Name or service not known

in gitlab.com-

SSH Key

  • Title: GIT-SSH Work laptop
  • Created on: Jan 2, 2022 6:14pm
  • Expires: Never
  • Last used on: Never

You are still doing it wrong:

ssh -T git@gitlab.com:IgorKu/date_recovery.git

no, when testing the connection, it is as I said:

ssh -T git@gitlab.com

See my example:

[ian@elise ~]$ ssh -T git@gitlab.com
Welcome to GitLab, @iwalker!

that is how you test the connection. You cannot do it like you do it.

1 Like

To use the full path with ssh for cloning, only then do you use like you were writing:

git clone git@gitlab.com:IgorKu/date_recovery.git

thanks a lot!
I will dare.

I did it.
I received the following in response-
user@user-laptop MINGW64 ~/.ssh
$ ssh -T git@gitlab
/etc/ssh/ssh_config line 2: no argument after keyword “$”
/etc/ssh/ssh_config: terminating, 1 bad configuration options

user@user-laptop MINGW64 ~/.ssh
$ ssh -Tvvv git@gitlab
OpenSSH_8.8p1, OpenSSL 1.1.1l 24 Aug 2021
debug1: Reading configuration data /c/Users/user/.ssh/config
debug1: /c/Users/user/.ssh/config line 2: Applying options for gitlab.
debug1: Reading configuration data /etc/ssh/ssh_config
/etc/ssh/ssh_config line 2: no argument after keyword “$”
/etc/ssh/ssh_config: terminating, 1 bad configuration options

I did it.
I received the following in response-
user@user-laptop MINGW64 ~/.ssh
$ ssh -T git@gitlab
/etc/ssh/ssh_config line 2: no argument after keyword “$”
/etc/ssh/ssh_config: terminating, 1 bad configuration options

user@user-laptop MINGW64 ~/.ssh
$ ssh -Tvvv git@gitlab.с
OpenSSH_8.8p1, OpenSSL 1.1.1l 24 Aug 2021
debug1: Reading configuration data /c/Users/user/.ssh/config
debug1: /c/Users/user/.ssh/config line 2: Applying options for gitlab.c
debug1: Reading configuration data /etc/ssh/ssh_config
/etc/ssh/ssh_config line 2: no argument after keyword “$”
/etc/ssh/ssh_config: terminating, 1 bad configuration options

oh yes
oh

Thanks iwalker !
I found a problem in the file, fixed it and connected.

Yes, there was a problem on line 2 of /etc/ssh/ssh_config - something here was most likely incorrectly configured