I 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:

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

    Windows 7 Cygwin Setup

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

    Cygwin Setup: Choose Installation Directory

    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 Setup: Packages Download

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

    Cygwin Setup: OpenSSH Package

    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.

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

    Cygwin OpenSSH Package Installation Progress

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

    Windows 7: SSH & SCP CLI 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.


List Price: $34.95 USD
New From: $17.00 USD In Stock
Used from: $14.29 USD In Stock


List Price: $69.95 USD
New From: $53.97 USD In Stock
Used from: $17.76 USD In Stock

DeliciousStumbleUponDiggTwitterFacebookRedditLinkedInEmail
Tags: , , , , , , , , , , , , , , , , ,
21 Responses to “How To Install SCP and SSH On Windows 7 Using Cygwin”
  1. Miguel says:

    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:

    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:

    Hello Jarom,

    Thanks for taking the time to respond with the proper information to Miguel above! Much appreciated.

    Thanks.
    alex

    [Reply]

    alex Reply:

    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:

    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]

  2. Alamgir Kahn says:

    Awesome. Thank you!

    [Reply]

    alex Reply:

    Hello Alamgir Kahn,

    No problem. Thank you for taking he time to leave feedback.

    Thanks.
    alex

    [Reply]

  3. Jason says:

    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:

    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]

  4. ted says:

    Thanx, that was really helpful and exactly what I was looking for.

    [Reply]

    alex Reply:

    Hello ted,

    No problem. Thanks for posting feedback.

    Thanks.
    alex

    [Reply]

  5. Pradeep says:

    Thanks a lot…

    [Reply]

    alex Reply:

    Hello Pradeep,

    No problem. Thanks for taking the time to leave feedback.

    Thanks.
    alex

    [Reply]

  6. satish says:

    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:

    Hello satish,

    You need to install a SSH server not the SSH client as mentioned in this article.

    Thanks.
    alex

    [Reply]

    satish Reply:

    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:

    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]

  7. satish says:

    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:

    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]

  8. Lesya says:

    Thanks a lot!

    [Reply]

  9. pharaon says:

    awesome post dude. very clear and very easy to follow.
    thanks for keep posting such posts

    pharaon

    [Reply]

  10.  
Leave a Reply

*Type the letter/number combination in the abvoe field before clicking submit.

*