Unable to connect to Gitlab Container on Custom Port via SSH

  1. I have a VMWare Player, it is running a local VM that is hosting the Gitlab Server based on official container repo. I have changed the ports as follows:

    Host → Container
    27→22
    85→80

  2. I can access gitlab at the address http://192.168.71.129:85/ from my browser.

  3. I added the SSH key using GitHub's Git PowerShell into my Gitlab account that I can access locally.

  4. I created a config file in my .ssh directory that has the contents as follows:

    #in gitlab.com server
    Host 192.168.71.129
    Port 27
    User git
    RSAAuthentication yes
    IdentityFile ~/.ssh/id_rsa
    
  5. When I try to push to my Gitlab account using the following commands as shown in Gitlab:

    cd existing_folder
    git init
    git remote add origin git@gitlabhost:someuser/secondtest.git
    git add .
    git commit
    git push -u origin master
    

I get the following error from the last statement:

ssh: Could not resolve hostname gitlabhost: Name or service not known
fatal: Could not read from remote repository.
Please make sure you have the correct access rights and the repository exists.

What setting am I missing? Any hints, suggestions?


ANSWERS:


According to the error message the hostname gitlabhost cannot be resolved:

ssh: Could not resolve hostname gitlabhost: Name or service not known

You put the server's IP address in your SSH config:

Host 192.168.71.129

but used a hostname when setting the origin of your repository:

git remote add origin git@gitlabhost:someuser/secondtest.git

There are two ways to resolve the issue:

  • Use the IP address in the origin:

    git remote add origin git@192.168.71.129:someuser/secondtest.git
    
  • Ensure proper name resolution, e.g. by adding a line like this to /etc/hosts:

    192.168.71.129    gitlabhost
    

Thanks Ansgar Wiechers, below is my netstat output

$ netstat -l -t -n
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State
tcp        0      0 127.0.0.1:9344          0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN
tcp        0      0 :::8089                 :::*                    LISTEN
tcp        0      0 :::27                   :::*                    LISTEN
tcp        0      0 :::85                   :::*                    LISTEN
tcp        0      0 :::22                   :::*                    LISTEN

Actually the problem was as you pointed out was the name resolution. I changed the command to just the IP address rather than host name and I was able to get it.

C:\Users\SomeUser\Documents\FirstPhPProj> git init
Initialized empty Git repository in C:/Users/SomeUser/Documents/FirstPhPProj/.git/
C:\Users\SomeUser\Documents\FirstPhPProj [master +6 ~0 -0 !]> git remote add origin git@192.168.71.129:alamabbas/secondtest.git
C:\Users\SomeUser\Documents\FirstPhPProj [master +6 ~0 -0 !]> git add .


 MORE:


 ? Centos 6.8 - Updates repo issues
 ? Centos 6.8 - Updates repo issues
 ? Centos 6.8 - Updates repo issues
 ? installing multiple gcc on centOS 7
 ? yum update error in centos 6.6
 ? Yum just stopped woiking and gives error
 ? Develop iOS swift app to mirror into a browser?
 ? Develop iOS swift app to mirror into a browser?
 ? Develop iOS swift app to mirror into a browser?
 ? ios app not fitting iphone screen