How to change ssh port on windows 10?

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?

1

3 Answers

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.

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

%programdata%\ssh\sshd_config

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.)

6

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

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

You Might Also Like