This post explains how to install a git lab instance on custom SSH and SSL ports.
For our example, we will install Git Lab Enterprise Edition onto a CentOS 7.
The Git Lab creators have provided detailed instructions on their website; please follow it if you have not already. Git Lab installation methods
Login to your CentOS 7 instance via SSH. Edit
/etc/ssh/sshd_config using your favorite text file editor. I like both
nano and change line
Port 22 to match your custom port. E.g.,
Port 3004. Save and run
systemctl restart sshd or
service sshd restart. Exit.
Re login to CentOS7 instance with new port again ( which looks like
ssh user@centos7 -p NEW_PORT_NUMBER, ) to check if the changes have taken effect. If you don’t see any error and you login successfully, you have successfully changed SSH port for your instance.
/etc/gitlab/gitlab.rb to tell git lab what port to use to connect via secure port on a browser and a custom port via SSH.
Edit line that starts with
external_url= and change it to something like
Add the following line
gitlab_rails['gitlab_shell_ssh_port'] = 3004 to the file and save. Make sure you change both port numbers above to ones of your choice or need.
gitlab-ctl reconfigure for changes to take effect.
Now go back to your Git Lab instance and check if the port number for secure URL looks like this
https://ns79.a1z.us:3002/user10/get-file-hash.git and port number for SSH URL matches the one you put in. It should look similar to
If so, you are done with changes on the server side!
The following is an example showing how to add a custom ssh repository URL and publish to it from a windows power shell command line.
(By the way, this is a real and usable code for your Internet Information Services server instance. Here is the URL: Get File Hash )
PS C:\inetpub\wwwroot\get-file-hash> git remote add ns79_ssh ssh://firstname.lastname@example.org:3004/user10/get-file-hash.git PS C:\inetpub\wwwroot\get-file-hash> git remote show ns79_ssh The authenticity of host '[ns79.a1z.us]:3004 ([188.8.131.52]:3004)' can't be established. ECDSA key fingerprint is SHA256:0H9phyOIOag7cWP5MeZtYMhi5sOi6UhrmXQVjC129oI. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added '[ns79.a1z.us]:3004,[184.108.40.206]:3004' (ECDSA) to the list of known hosts. * remote ns79_ssh Fetch URL: ssh://email@example.com:3004/user10/get-file-hash.git Push URL: ssh://firstname.lastname@example.org:3004/user10/get-file-hash.git HEAD branch: (unknown) PS C:\inetpub\wwwroot\get-file-hash> git push -u ns79_ssh master Counting objects: 7, done. Delta compression using up to 2 threads. Compressing objects: 100% (6/6), done. Writing objects: 100% (7/7), 2.83 KiB | 414.00 KiB/s, done. Total 7 (delta 0), reused 0 (delta 0) To ssh://ns79.a1z.us:3004/user10/get-file-hash.git * [new branch] master -> master Branch 'master' set up to track remote branch 'master' from 'ns79_ssh'. PS C:\inetpub\wwwroot\get-file-hash>
Congratulate yourself for successfully installing a git lab instance on custom SSH and SSL ports!