AVAILABLE: 5
Are you comfortable with Linux/Unix and want SSH access to your Windows 7 machine? Cygwin provides this functionality, offering a familiar environment to work in with just a few simple steps.
We assume you have already installed and configured Cygwin. If not, check out our guide:
"How to Use Linux Commands on Windows with Cygwin"
1. Installing OpenSSH
OpenSSH is what we'll use, so if you haven't installed it yet, locate the setup.exe
file for Cygwin and run it.
You can keep all the default settings as when you set up Cygwin. On the package selection screen, search for "open" under the "Net" section.
You'll find a package named "openssh." Click under the "New" column, where it says "Skip," until an "X" appears in the "Bin?" column. Refer to the screenshot if you're unsure. Click "Next" and complete the remaining setup process.
2. Configuring OpenSSH in Cygwin
Unlike most Linux distributions, OpenSSH will not automatically configure itself to run and function. We need to follow a few simple steps. First, right-click your Cygwin shortcut and select "Run as administrator":
This ensures administrative privileges are granted. A blank Cygwin window will open. Enter the following command:
ssh-host-config
The script will generate some default files and ask if you want to enable Privilege Separation. This is enabled by default in standard OpenSSH installations, so type yes
.
You’ll then be prompted to create a new account with special privileges. Choose yes
and let the script proceed.
Next, it will ask if you want to run it as a service. This allows SSH access whether or not Cygwin is running. Type yes
to continue.
Finally, you’ll be asked to provide a value for the daemon. Enter the following command:
ntsec
The script will display some system information and prompt you to create a privileged account with the default username cyg_server
. The default works fine. Type no
if you prefer a different account name, but you can change it anytime later.
You will need to set a password for this account.
Cygwin will display your password in plain text for verification, so ensure you're in a secure location. If all goes well, you’ll receive a message indicating successful completion.
To start the service without restarting, enter the following command:
net start sshd
You can then type exit
to close this instance of Cygwin.
3. Configuring SSH Users
Next, we’ll generate the appropriate SSH keys for your user account. Open Cygwin normally and enter the following command:
ssh-user-config
You’ll be prompted to create a key specific to your user account. Use the options you need. I opted for no
to the first question and yes
to the second.
SSH2 is more secure, so I recommend it. After setting a password, you’ll be asked if you want to use that ID to access your machine. Type yes
.
You’ll then be prompted to create an SSH2 DSA ID file, which you might want for password-less access. I skipped this step.
Configuration is now complete! To quickly test it, enter the following command:
ssh --v localhost
The --v
option stands for "verbose" and provides detailed information about the process. You’ll be asked if you want to proceed with the connection, so type yes
and enter your password when prompted. Remember, your username is case-sensitive!
If everything works, you’ll see the normal bash prompt.
4. Minor Issues
If you get stuck during any of the configuration steps, ensure the Windows User Account you're using has Administrative access. You might encounter errors if you try running the host configuration as a regular user, so always run Cygwin with admin privileges for that step. When exiting, if you’re prompted about batch jobs, you can safely press no
to stop them.
Lastly, if you’re testing SSH access from another computer and encounter errors, check that your firewall isn’t blocking access to port 22 (or 23 if you’re using SFTP).
This setup works excellently if you want SSH/SFTP access to your files on a Windows 7 machine while using a familiar shell environment. Cygwin mounts Windows drives to /cygdrive/driveletter
if you’re curious. ;-)