I'm working on aws cloud image which requires an ssh connection to connect. But my service provider has blocked the port 22 so I can't connect to cloud image. So how can I change Ssh configuration to change the port number from 22 to something other?

  • I have cmder and git-bash installed on windows. – V2K Nov 12 '19 at 13:05

If you are trying to change the SSH port in a Windows 10/Server 2016/2019 ,you can change the port in the below file


Locate the line that starts with Port and edit it there.


You say Windows 10 but of course Windows doesn't natively use ssh. Though you can install bash or some other shell via the Linux Subsystem for Windows. This, I trust, is what you mean. Here are some basic instructions for changing the file containing the port information:


1:  find / -name "sshd_config" 2>/dev/null 
2:  sudo nano /path/to/file  ##  probably /etc/ssh/sshd_config 
3:  ## locate Port 22 (removing any leading #) 
4:  ctrl-o # save the file 
5:  ctrl-x # exit nano 

Once you have changed it you simply add the port designation to your ssh command when attempting to connect.

ssh username@host:port

(You may need to make firewall changes if there is one in between. It depends on the specifics of your arrangement.)

  • I had install cmder and git-bash shell on windows. Is any of the shell configurations help for changing the port from 22 to some other port. – V2K Nov 12 '19 at 13:05
  • The instructions above should be approximately correct for any shell you have installed. Let me know if you run into any specific issues. – JamesIsIn Nov 12 '19 at 13:12
  • Can i change it without installing any linux sub-system. Can i do it only with the use of cmder. – V2K Nov 12 '19 at 13:24
  • If cmder gives you bash, then you ought to be able to do just the same. The Subsystem was what I was assuming you were using to get bash. (It works great if you are having any issues with cmder.) – JamesIsIn Nov 12 '19 at 13:28
  • 1
    Windows 10 does support OpenSSH now, both server and client. It can be activated via Settings App within Windows, google it. – Jimmy Falcon Apr 5 '20 at 9:45

Nowadays, you can change the SSH port on Windows 10 easily (as mentioned by others).

All you need is in this Microsoft documentation page.

Brief look at:

  1. Install SSH server;
  2. Change port in config file %programdata%\ssh\sshd_config (for Windows):
    enter image description here
  3. Add new firewall rule with PowerShell running following command as Administrator:
    New-NetFirewallRule -Name sshd -DisplayName 'OpenSSH Server (sshd)' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 2204
    where 2204 your port;
  4. Restart your 'SSH server' windows service;
  5. (optional) Delete firewall rule for default 22 port.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.