Connect to private repository using ssh keys with non-standard SSH port

Jul 24, 2018
14
3
3
Romania
cPanel Access Level
Website Owner
On my WHM, I have changed the default SSH port from 22 to 56022 using CSF, for security reasons. Now, port 22 is removed from TCP IN and OUT open ports list.
I am able to connect and use the new 56022 port, but now I have a problem with my BitBucket repository connection:

Code:
ssh: connect to host bitbucket.org port 56022: Network is unreachable
fatal: Could not read from remote repository.
The repository was configured and used before the SSH port changing when everything was working fine, but now, it doesn't work anymore with regular commands like git pull or similar.
If there is a cPanel related help or any suggestions are welcome
 
Last edited by a moderator:

ffeingol

Well-Known Member
PartnerNOC
Nov 9, 2001
633
209
343
cPanel Access Level
DataCenter Provider
I may be mis-reading your post, but changing the SSH port on your server has no effect on the SSH port for bitbucket.org. You'd still use whatever their SSH port is. You just need to make sure that your outbound firewall rules allow the bitbucket.org SSH port.
 
Jul 24, 2018
14
3
3
Romania
cPanel Access Level
Website Owner
I may be mis-reading your post, but changing the SSH port on your server has no effect on the SSH port for bitbucket.org. You'd still use whatever their SSH port is. You just need to make sure that your outbound firewall rules allow the bitbucket.org SSH port.
Well, everything was working fine before I changed the port. Maybe it's because I removed the 22 port for TCP OUT too .. ? But why the error says that it tries to connect to the new SSH port ? Because this port was only to reach my server and not any outgoing ssh connections.. like Bitbucket in this case..
 
Jul 24, 2018
14
3
3
Romania
cPanel Access Level
Website Owner
Added port 22 back to TCP_OUT list and restarted CSF and ssh service, but looks like I have the same error, like it tries to connect to the new SSH port 56022. Don't know why.. should I specify somehow within the repository to connect to port 22? It's very strange
 

wintech2003

Well-Known Member
PartnerNOC
Sep 15, 2010
103
28
78
Greece
cPanel Access Level
DataCenter Provider
Is it possible that you also changed the Port setting in the /etc/ssh/ssh_config file? The SSH server's settings are in /etc/ssh/sshd_config
If you added "Port 56022" under Host * in /etc/ssh/ssh_config (which is the SSH client's configuration) then indeed all your outgoing SSH connections will default to port 56022.
 

andrew.n

Well-Known Member
Jun 9, 2020
674
209
43
EU
cPanel Access Level
Root Administrator
I agree with @wintech2003 it could be that you adjusted ssh_config as it wouldn't use port 56022 for outgoing connections otherwise.
 
  • Like
Reactions: cPRex