How to access SSH on Windows 7 using Cygwin
If you are comfortable using Linux / Unix and want to access SSH on a Windows 7 computer, you can use Cygwin. This Windows Linux emulator provides this functionality and gives you a familiar work environment with just a few simple steps.
This article does not cover the installation and configuration of Cygwin, if you do not know how to do it, you can refer to the article Using Linux in Windows with Cygwin.
Install OpenSSH
Here we will use OpenSSH, so if not installed, find the setup.exe file and run it.
You can keep all the default values just like when you set up the original Cygwin. On the package selection screen, search for ' open ' and look in the ' Net ' menu.
You will see a package called " openssh ", click on the " New " column and see " Skip " until the X appears in the " Bin? " Column. Look at the screenshot above to know what to choose if you're confused. Then click " Next" and complete the remaining setup process.
Configure OpenSSH in Cygwin
Unlike most Linux distributions, OpenSSH will not automatically configure to run and operate. We need to take a few simple steps. First, right click on Cygwin shortcut and click on ' Run as administrator '.
This ensures you have the right rights to do everything. You will then see an empty Cygwin window appear.
Enter the following command:
ssh-host-config
You should see the script create some default files and then you will be prompted if you want to enable ' Privilege Separation '. By default, it will be enabled in standard OpenSSH settings on other systems, so continue and select " yes ".
You will be prompted to create a new account with special permissions, select ' yes ' and the script will continue.
Next, you will be asked if you want to run sshd as a service. This gives you SSH access even when Cygwin is not running. If yes, type yes to continue.
Next, you will be asked to enter a value for the daemon. Enter the following command:
ntsec
You will see the script provide some information on the system and ask you to create a special account with the default username ' cyg_server '. Leave the default settings unchanged and type ' no ' when you ask if you use a different account name, although you can change this if you like.
Of course, you will also have to enter the password for this account.
Cygwin will display your password in plain text for verification, so make sure you are in a safe place. You will see some additional information appear and if all is done correctly, you will receive a message telling you that the configuration is complete.
You can restart or enter the following command to start the sshd service:
net start sshd
Now, you can type " exit " to close Cygwin.
User configuration of SSH
Next, you need to create the appropriate SSH keys for your user account. Open normal Cygwin and enter the following command:
ssh-user-config
You will be asked to create specific keys for your user account, so use what you need. In this example, type ' no ' for the first question and ' yes ' for the second question.
SSH2 is more secure, so you can use it. After entering the password, you will be asked if you want to use that ID to access your device, type ' yes '.
Next, you will be asked to create an SSH2 DSA ID file, if you want to use access without a password, you can decline at this step.
So you've configured it. If you want to check the quick configuration, enter the following command in the Cygwin window:
ssh –v localhost
The -v option stands for "verbose" and gives you all the information of the process. You will be asked if you want to continue connecting, so enter ' yes ' and then enter your password at the prompt. Remember that when entering your username, it will be case sensitive.
If everything works well, you will see the usual bash prompt.
Problems when setting up SSH access
If you are stuck at any configuration step, make sure that your Windows User Account is running with administrative access. You can get some strange errors if you run a host request with a normal user account, so be sure to run Cygwin with admin rights during that step. If you exit, you receive a prompt about the batch job running, press no to stop this.
Finally, if you check for SSH access from another computer and see an error, make sure your firewall doesn't block access to port 22 (or 23 if using SFTP).
This method works very well if you like the ability to access SSH / SFTP on files on a Windows 7 computer and you also want a familiar shell to do so. If you're wondering, Cygwin attaches a Windows drive to '/ cygdrive / driveletter '.
I wish you all success!
See more:
- How to activate and use SSH commands on Windows 10
- Back up the entire website with SSH Command Line
- How to install OpenSSH on Windows 10
You should read it
- Manage the Event Log with the command line
- How to Use Cygwin
- 5 best command line emulation software for Windows 10
- Forget the GUI, the Command Line is returning
- 10 useful commands in Windows you should know
- 10 tips for using Command Line Windows 10 users should know
- Command line parameter in C
- Instructions for using Command Prompt
- All cmd and dos commands on Windows
- How to use the command history function in Command Prompt
- Reg regini command in Windows
- The Nox App Player command line parameters support