Change the default port the SSH daemon is running on.
This is guide is intended to be complete in order to run a setup a complete GitLab environment.
Why do we want to change the default port the SSH daemon is running on ?
- Security; when we are exposing our SSH daemon to the internet we don't want it to be visible to the outside world on the default port.
GitLaballows repository access over SSH, so by moving the default SSH daemon to a different port, port 22 becomes available to be used by
GitLabfor remote access.
For this guide we will assume the SHS daemon is already installed.
- Login to your server with SSH
- Switch to a
sudo su -
- Open your SSH daemon configuration with vi
- When opening a file in
viwe are in what's called the
Command Modethis allows us to give
vicommands and to move around in the file
This will move your cursor to the line starting with
- If the line starts with
#then the port configuration is not active meaning that the daemon will default to port
We are assuming that with the previous command in step 4 the cursor is now highlighting the
- In order to remove the
#is present on the line, type:
h, this will move the cursor one to the left, and the
#is now highlighted by the cursor.
xto remove the character.
- In order to change the port type:
This will move the cursor to the end of the line and go into
This can be verified by the bottom of your screen, it should say:
-- INSERT --
- Now we can change the port to
32. Use backspace and change the port to
- The line should now read:
In order to save the changes we need to go back into
This is done by pressing
At the bottom the next
-- INSERT --should no longer be present.
In order to save the file we type:
!-> Don't ask for confirmation
- Restart the SSH daemon
systemctl service sshd restart
- You can now reconnect to your server with
ssh user@host -p 32