I have an instance of the following docker-compose
file running:
version: '3.6'
services:
web:
image: 'gitlab/gitlab-ee:latest'
restart: always
hostname: '135.181.27.5'
container_name: 'gitlab'
#environment:
# GITLAB_OMNIBUS_CONFIG: |
# external_url 'http://135.181.27.5'
# # Add any other gitlab.rb configuration here, each on its own line
ports:
- '80:80'
- '443:443'
- '222:22'
volumes:
- '/var/gitlab/config:/etc/gitlab'
- '/var/gitlab/logs:/var/log/gitlab'
- '/var/gitlab/data:/var/opt/gitlab'
shm_size: '256m'
I mapped port 22 to 222 since the port 22 is used by me to access the server.
Everything is fine but when I add a public ssh key to my gitlab instance and trye to clone a repo via the following command:
git clone [email protected]:root/python-demo-cicd.git
The result is:
Cloning into 'python-demo-cicd'...
[email protected]'s password:
Is the problem the port mapping from 22 to 222? If yes then how can I use port 222 instead of 22 for git purpose?
CodePudding user response:
The default ssh port for git clone git@host:path/to/repo.git
is 22, to use a different port change that to git clone ssh://git@host:222/path/to/repo
.
You can add tthis to your ~/.ssh/config
to keep using short git@host
, but that does not scale well for others...
match host 135.181.27.5 user git
port 222