'How to change the ssh port connection on Windows?

I am trying to connect to GitLab with an ssh key from a Windows laptop. The problem is the port of the repository has changed, and I cannot manage to change the default port 22 on the config.

I have tried with a mac laptop and it worked by editing the config file, but I cannot do the same on Windows. I created a config file with touch config and added this

Host gitlab.com
   HostName gitlab.com
   PreferredAuthentications publickey
   IdentityFile ~/.ssh/id_rsa
   Port 1122

But it does not work, terminal says it is still connecting to port 22:

C:\Users\parko>ssh -T [email protected]   
kex_exchange_identification: read: Connection reset                                                                                                                                                                                      
C:\Users\parko>ssh -T git@gitlab.%myRepository%.com                                                          
ssh: connect to host gitlab.%myRepository%.com port 22: Connection timed out    

I also tried a solution that I found in an article to change the port directly on the command when trying to connect, but it also did not work:

C:\Users\parko>ssh -T git@gitlab.%myRepository%.com:1123
ssh: Could not resolve hostname gitlab.%myRepository%.com:1123: No such host is known.

Any idea what can be happening? Thanks in advance.



Solution 1:[1]

Like @ewong said, I had to add the port with the -p parameter instead of at the end of the command

ssh -p [port number] -T git@[gitlab URL]

for me it was:

C:\Users\parko>ssh -p 1123 -T git@gitlab.%myRepository%.com

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 parkorian