Search This Blog

Wednesday, August 17, 2011

sshd in cygwin

Following commands should be executed with root privilege.

ssh-host-config -y 
- In this command, it will ask the user name and password. The user name will be used for running the service.

cygrunsrv -S sshd 
- With this command, it will start the sshd. 

cygrunsrv -E sshd 
- With this command, it will end the sshd

cygrunsrv -R sshd 
- With this command, it will remove the sshd. In this case, it is necessary to re-run ssh-host-config again.

You may want to change the port ssh is using. In this case, you need to edit '/etc/sshd_config.' Replace the old port number (typically it is 22) with new one. Original configuration in that file would be the following:

Port 22

If you want to add the port for exceptions in your firewall, you may want to run the following command.

netsh firewall add portopening TCP #port OPRule_#port ENABLE

where #port is the port number you want to use.

For a newer version of the Windows firewall (probably after Windows 10), the following command can be used ('netsh firewall' is deprecated).

netsh advfirewall firewall add rule name="OPRule_#port" dir=in action=allow protocol=TCP localport=#port

Remove sshd from cygwin

1. Stop and remove sshd service.

cygrunsrv -S sshd 
cygrunsrv -R sshd

2. Remove any related user account information in /etc/passwd. Specifically, remove sshd and cyg_server account information.

3. Remove any related user account.

net user sshd /delete
net user cyg_server /delete

No comments:

Post a Comment

Blog Archive