How To Install SCP and SSH On Windows 7 Using Cygwin
Posted by alex in Insights at 10:47 AMI use Cygwin on Windows to make my Windows only computers as comfortable as possible to me. This comfort is provided by the Linux command line utilities that allow me to work. Cygwin provides a way for me to run these utilities from a Windows 7 command prompt. Two utilities that are really useful that are not installed with Cygwin by default are SCP (Secure Copy) and SSH (Secure Shell). Both of these utilities allow secure communication with remote computers. Below I describe adding them to an existing Cygwin Windows 7 installation.
Use Cygwin To Install SCP & SSH On Windows 7:
- Launch Cygwin Setup: Whenever you add new packages to Cygwin you simply launch the setup.exe file again as if installing from scratch. The Cygwin setup can be downloaded by clicking here. Once you have the setup.exe click on it to launch Cygwin on Windows 7 as displayed below.
- Continue Cygwin Setup: Follow the Cygwin prompts all the way to package selection. This article assumes that Cygwin is already installed so you should know all of the necessary configuration items including preferred download source, root install directory (example displayed in below image), local package directory, Internet connection, and a download site.
Again make sure that you use the same configuration options as when you first installed Cygwin so there is not any confusion for which applications are the correct ones. The most important configuration option, which is installation directory, is displayed in the above image. Once you have clicked the Next button and made all of the correct configuration changes you will see the download of the packages list from your preferred download source which in my case was ftp.gtlib.gatech.edu. You can see an example of the packages download below.
- Cygwin Package Selection: There are tons of awesome packages that can be installed on Windows 7 however in this example we simply ant the SCP and SSH commands to be available so we will need to install the openssh package. After the packages have been downloaded in step two you will see a list of available package categories by default. Type “openssh” into the Search field which will limit the categories listed below to only the Net category. Click the + sign to the right of the Net category to display the available packages that match openssh. There currently is only one package on Cygwin that matches openssh, currently version 5.3p1.1, as displayed in the below image.
Once the openssh package is displayed underneath the Cygwin Net category you need to click the Skip text underneath the “New” column until it shows an X in the “Bin?” column. This is telling Cygwin to add this package to the list of installed packages. You do not need the source unless you plan to custom modify the application. The openssh package is the one that includes the Linux CLI applications SSH and SCP. SSH allows you to securely connect to remote devices and SCP allows you to securely copy files to remote devices. The types of devices includes computers, servers, routers, switches, etc.
- Install SSH & SCP On Windows 7: Now that the package has been selected you can continue by clicing the Next button which will begin installing the openssh package as displayed below.
- Verify Installation: After the package is installed click the Finish button on the final Cygwin screen. You should now test SSH and SCP to make sure they are working properly. If the Cygwin bin directory has been added to your PATH then you can simply open up a Console or Command Prompt window and type ssh or scp as displayed in the below image. If the Cygwin bin directory is not in your PATH then navigate to the Cygwin bin directory and issue the same commands.
You now have SCP and SSH on your Windows 7 computer! So far I have been really impressed with Windows 7 and being able to make it as close as possible to Linux while still getting the benefits of Adobe products and Microsoft Office products has been awesome.
|
|
|
|




Entries (RSS)
Hi,
For public key authentication, where will SSH look for the public key?, would it be c:\Users\user_name\ssh ??
Thank you
[Reply]
Jarom Reply:
April 21st, 2010 at 4:24 PM
SSH will look for your public and private keys in
/home/user_name/.ssh
In Windows paths, this is likely somewhere like
C:\cygwin\home\user_name\.ssh
[Reply]
alex Reply:
April 21st, 2010 at 11:34 PM
Hello Jarom,
Thanks for taking the time to respond with the proper information to Miguel above! Much appreciated.
Thanks.
alex
[Reply]
alex Reply:
April 21st, 2010 at 11:33 PM
Hello Miguel,
Exactly as Jarom says above so for instance the path to the SSH public key on my laptop with cygwin installed in C:\cygwin it would be “C:\cygwin\home\alex\.ssh”. So if you are unsure of where cygwin is installed on your Windows computer simply search for the home directory.
Thanks.
alex
[Reply]
Miguel Reply:
April 22nd, 2010 at 4:17 AM
Thank you guys for the swift reply, I managed to get it to work after some trial error. It really helps a lot if you run ssh in verbose mode (ssh -v). My server side cvs account had a .ssh folder with the private (id_rsa) and public (id_rsa.pub) keys, the later also in authorized_keys (cat id_rsa.pub > authorized_keys) and the .ssh directory had the correct access permissions (chmod 755 .ssh). I had copied the public key across to my c:\cygwin\home\user\.ssh (also with the correct permissions) in the client side but when I run ssh to connect in verbose mode to the server I realized that I also needed to have the private key in the client side (weird though as I though that was). I have two windows client machines, with two different versions of cygwin. One of them wanted my private key to be named ‘id_rsa’ and the other ‘identity’… once this was in place and c:\cygwin\bin in my PATH i could run ssh from a windows command window…
Regards,
[Reply]
Awesome. Thank you!
[Reply]
alex Reply:
July 23rd, 2010 at 6:26 AM
Hello Alamgir Kahn,
No problem. Thank you for taking he time to leave feedback.
Thanks.
alex
[Reply]
I have done the installs of Cygwin. I am attempting to remote securely over rdp from a winxp to a win7 box. I am confused on the commands to make this happen. Can anyone give me a “for dummies” explanation of how to initiate the ssh connection over rdp? I do have ports 3389 and 22 open on the router, which are needed for this, based on my googling so far
[Reply]
alex Reply:
November 11th, 2010 at 10:55 AM
Hello Jason,
I have never done this specific task but you should be able to get all of the information you need from the SSH man page. I believe you can accomplish what you want to do by using the “-R” switch. Would love to hear what the final command is so others might find the info useful.
Thanks.
alex
[Reply]
Thanx, that was really helpful and exactly what I was looking for.
[Reply]
alex Reply:
April 23rd, 2012 at 5:23 AM
Hello ted,
No problem. Thanks for posting feedback.
Thanks.
alex
[Reply]
Thanks a lot…
[Reply]
alex Reply:
April 3rd, 2012 at 1:55 AM
Hello Pradeep,
No problem. Thanks for taking the time to leave feedback.
Thanks.
alex
[Reply]
i have installed cigwin on windows 7. also install VM on the same windows7 box and installed OEL5. now i want to configure ssh between windows 7 and linux vm. i could copy files from windows7 to linux using scp. but i am not able to copy from linux to windows7.
error:
[root@LINUXmachine1 .ssh]# scp authorized_keys Govind@WINDOWS7:.ssh/authorized_keys
ssh: connect to host 192.168.79.1 port 22: Connection timed out lost connection
please help me ASAP.
[Reply]
alex Reply:
July 19th, 2012 at 12:54 PM
Hello satish,
You need to install a SSH server not the SSH client as mentioned in this article.
Thanks.
alex
[Reply]
satish Reply:
July 20th, 2012 at 12:35 AM
but openssh client and server packages are installed on cigwin. my doubt is , win7 might be stoping the scp request. is there any firewall setting?
[Reply]
alex Reply:
July 20th, 2012 at 1:02 AM
Hello satish,
I dunno do you have a firewall running? Is port 22 listening? What interfaces is it listening on? Can you SSH to localhost from the Windows box itself? The more details you provide along with what the actual issue is would be the only way we could provide any useful assistance or suggestions.
Thanks.
alex
[Reply]
i could do ssh locally. i am copying it below. and i have poor knowledge on windows. so help me in finding out , windows 7 is blocking 22 port or firewall . so please help me.
Govind@SATISH-PC ~
$ ssh Govind@localhost
The authenticity of host ‘localhost (::1)’ can’t be established.
ECDSA key fingerprint is 16:4d:71:e0:74:83:0e:0b:71:73:e8:fa:91:4b:18:d7.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added ‘localhost’ (ECDSA) to the list of known hosts.
Govind@localhost’s password:
Govind@SATISH-PC ~
$ exit
logout
Connection to localhost closed.
Govind@SATISH-PC ~
$
[Reply]
alex Reply:
July 20th, 2012 at 1:45 AM
Hello satish,
I can only help so much here. You need to use netstat to see what interfaces SSH is listening on and then you need to look at the Windows 7 firewall configuration to see if port 22 connections are on. You could also temporarily turn the firewall off to see if it is indeed a firewall issue. That is the only advice that I can provide unless you want to pay for consulting services which you can initiate by using the contact form on the site.
Thanks.
alex
[Reply]