Best way to enable/install SSH with WAMP
Posted by: funkyfrank (179.43.144.---)
Date: August 02, 2015 02:17AM

To be able to have SSH with WAMP what would be the (best) proposed procedure please?

I see the openssl extension is loaded, so can I simply edit the httpd.conf file to enable SSH on the server?

Do I need to install an additional extension so that I can indeed use SSH on the local WAMP stack or do I need to install SSH on top of WAMP somehow?

I see www.itefix.net/copssh , www.openssh.com or www.bitvise.com/winsshd and various others.

How can I get SSH going with WAMP please?

Thank you for help with this.

If it is even just a link or two to a good post/tut explaining everything in detail I will happily gulp that down.

Kind Regards
Frank

Version of Operating system? Windows 7 Ultimate 64bit
Version of Wamp Server installed? 2.5 32bit
Version of Apache you are running? 2.4.9
Version of MySQL you are running? 5.6.17
Version of PHP you are running? 5.5.12
What colour is your WampManager icon? Green
Host file localhost 127.0.0.1

New to WAMP?
Read this please: [forum.wampserver.com]

Options: ReplyQuote
Re: Best way to enable/install SSH with WAMP
Posted by: RiggsFolly (---.as43234.net)
Date: August 02, 2015 02:33PM

Frank,

This is a little old now, but you shoudl be able to work out what you need to do from this.



How to Configure WAMPServer to use HTTPS SSL


This is not a trivial process. This tutorial will, hopefully, get SSL working for you.
However getting it configured to match your secific requirements once it is working is TOTALLY DOWN TO YOU.

Additional reading for all who travel this road
Remember this is Apache and PHP we are configuring here and not WAMPServer, so it is all documented on the Apache and PHP sites if you get any issues or have any specific requirements.

Ok,

I have based this tutorial on the creation of a site called www.wamphelpers.dev So whereever you see that name change it to the site name you are trying to secure.

I started by creating a unsecured site, in \wamp\www\wamphelpers

added a Virtual Host for that site, in httpd-vhosts.conf

<VirtualHost *:80>
    DocumentRoot "c:/wamp/www"
    ServerName localhost
    ServerAlias localhost
    <Directory  "c:/wamp/www">
        AllowOverride All
        Require local
    </Directory>
</VirtualHost>

<VirtualHost *:80>
    DocumentRoot "c:/wamp/www/wamphelpers"
    ServerName wamphelpers.dev
    ServerAlias www.wamphelpers.dev
    <Directory  "c:/wamp/www/wamphelpers">
        AllowOverride All
        Require local
    </Directory>
</VirtualHost>

Added its name to the C:\windows\system32\drivers\etc\hosts

127.0.0.1 wamphelpers.dev www.wamphelpers.dev
::1       wamphelpers.dev www.wamphelpers.dev


Now restart the dnscache as follows from a command windows launched using 'Run as Administrator'

net stop dnscache
net start dnscache


Then created a simple script in \wamp\www\wamphelpers\index.php

<?php
    echo 'Hello, this is the WAMPHELPERS.DEV site homepage';
?>

Now restart Apache and make sure that your simple unsecured site is working before continuing


---------- The openssl toolkit. ----------

The openssl.exe, ssleay32.dll and libeay32.dll come with, and are located in, the C:\wamp\bin\apache\apachex.y.z\bin folder
This should be all you need to create your self signed certificate !!




---------- Generate keys and Certificates. ----------

STEP 1: Generate an RSA Private Key

First we need to create ourselves a certificate.
The normal (paid for) process is to create your certificate and then pass it to a signing authority.
This is why it costs money, as they have to do, due dilligence, to check that you are who you say you are and that site that you will use the certificate on is real and legitimate.

The openssl toolkit is used to generate an RSA Private Key and CSR (Certificate Signing Request) to be used for our Certificate.
The first step is to create your RSA Private Key.
This key is a 1024 bit RSA key which is encrypted using Triple-DES and stored in a PEM format so that it is readable as ASCII text.


Open up a Command window (Dos box) using Run as Administrator
Change Directory to where you installed the OpenSSL Toolkit above.
In my case this is

set openssl_conf=c:\wamp\bin\apache\apache{apache_version}\conf\openssl.cnf
CD c:\wamp\bin\apache\{apache_version}\bin

Make a folder for the output to be put in ( to keep the bin folder tidy ) I used website
md website

Now enter this command:
openssl genrsa -out website\server.key 2048

This should have created a file in the 'website' folder without a pass phrase key, check it exists.


Step 2: Generate a CSR (Certificate Signing Request)

During the generation of the CSR, you will be prompted for several pieces of information.
These are the X.509 attributes of the certificate.
One of the prompts will be for "Common Name (e.g. server FQDN or YOUR name) []:".
It is important that this field be filled in with the fully qualified domain name of the server to be protected by SSL.
So if the website to be protected will be `[www.wamphelpers.dev]`, then enter `www.wampheplers.dev` at this prompt.

Do not enter anything to the question: A challenge password []:] - Just press Enter.
If you do enter a passphrase here when you come to start Apache with SSL configured Apache will not start and will give this error message :-

*[error] Init: SSLPassPhraseDialog builtin is not supported on Win32*

Basically if you do enter a passphrase Apache is supposed to challenge you for that passphrase each time it starts.
This is obviously not going to make your life any easier but primarily on windows it does not actually work and will
cause Apache to crash when it attempts to ask for the passphrase, with the above error.

The command to generate the CSR is as follows:
openssl req -new -key website\server.key -out website\server.csr


Example question and answers:
    Country Name (2 letter code) [AU]:GB
    State or Province Name (full name) [Some-State]: Hampshire
    Locality Name (eg, city) []: Portsmouth
    Organization Name (eg, company) [Internet Widgits Pty Ltd]: Wamp Helpers Ltd
    Organizational Unit Name (eg, section) []: Information Technology
    Common Name (e.g. server FQDN or YOUR name) []: www.wamphelpers.dev
    Email Address []: me@wamphelpers.dev

    Please enter the following 'extra' attributes
    to be sent with your certificate request
    A challenge password []: ( leave blank just hit the enter key )
    An optional company name []: ( leave blank just hit the enter key )

Step 3: Generating a Self-Signed Certificate

At this point you will need to generate a self-signed certificate because you either don't plan on having your certificate signed by a CA, or you wish to test
your new SSL implementation while the CA is signing your certificate.

openssl x509 -req -days 365 -in website\server.csr -signkey website\server.key -out website\server.crt

PRE - WARNING
Because we are not getting this certificate signed by a Certificate Authority, this certificate will generate an error in the client browser to the effect that
the signing certificate authority is unknown and not trusted.
This is unavoidable as we are signing the certificate ourselves, but of course the web of trust does not know who we are.
See example later in this document showing how to tell your browser that you actually trust this certificate


Example output:
Loading 'screen' into random state - done
Signature ok
subject=/C=GB/ST=Hampshire/L=Portsmouth/O=WampHelpers Ltd/OU=Information Technology/CN=www.wamphelpers.dev/emailAddress=riggsfolly@wamphelpers.dev
Getting Private key

Step 4: Installing the Private Key and Certificate

Create these 2 directories under the version of Apache you are using.

md c:\wamp\bin\apache\apache{apache_version}\conf\ssl.key
md c:\wamp\bin\apache\apache{apache_version}\conf\ssl.crt

And copy the file we have just generated into them like so:
copy website\server.crt c:\wamp\bin\apache\apache{apache_version}\conf\ssl.crt\
copy website\server.key c:\wamp\bin\apache\apache{apache_version}\conf\ssl.key\


Step 5: Configure Apache to activate SSL

Edit httpd.conf, Check that these lines are uncommented
LoadModule ssl_module modules/mod_ssl.so

LoadModule socache_shmcb_module modules/mod_socache_shmcb.so

Remove the comment '#' from this line also
Include conf/extra/httpd-ssl.conf

Then move that line after this block <IfModule ssl_module>.... </IfModule> like so

<IfModule ssl_module>
SSLRandomSeed startup builtin
SSLRandomSeed connect builtin
</IfModule>

# Secure (SSL/TLS) connections
Include conf/extra/httpd-ssl.conf


Step 6: Configure PHP to activate SSL

Edit your php.ini ( use the wampmanager menus so you edit the correct one )

Remove the comment ';' from this line
extension=php_openssl.dll


Step 7: Configure your secure sites Virtual Host

Yup for all you Virtual Host nay sayers, now you cannot avoid the process.

Edit "\wamp\bin\apache\apache{apache_version}\conf\httpd-ssl.conf"

This file is released by Apache and contains some default file location.
We can leave most of this file as it is, but we need to configure the virtual host in here to match our actual sites location and a few other things so:

find these lines
DocumentRoot "c:/Apache2/htdocs"
ServerName www.example.com:443
ServerAdmin admin@example.com
ErrorLog "c:/Apache2/logs/error.log"
TransferLog "c:/Apache2/logs/access.log"

and change them to
    DocumentRoot "c:/wamp/www/wamphelpers"
    ServerName wamphelpers.dev:443
    ErrorLog "c:/wamp/logs/ssl_error.log"
    TransferLog "c:/wamp/logs/ssl_access.log"

Find
SSLCertificateFile "c:/Apache2/conf/server.crt"

and change to
SSLCertificateFile "c:/wamp/bin/apache/apache{apache_version}/conf/ssl.crt/server.crt"

Find
SSLCertificateKeyFile "c:/Apache2/conf/server.key"

and change to
SSLCertificateKeyFile "c:/wamp/bin/apache/apache{apacheversion}/conf/ssl.key/server.key"

Find
<Directory "c:/Apache2/cgi-bin">
    SSLOptions +StdEnvVars
</Directory>

and change to
<Directory "c:/wamp/www/wamphelpers">
    SSLOptions +StdEnvVars
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    Order Deny,Allow
    Deny from all
    Allow from 127.0.0.1 localhost ::1
</Directory>


Find
SSLSessionCache        "shmcb:c:/Apache2/logs/ssl_scache(512000)"
SSLSessionCacheTimeout  300

and change it to
SSLSessionCache        "shmcb:c:/wamp/logs/ssl_scache(512000)"
SSLSessionCacheTimeout  300
Find
<Directory "c:/Apache2/cgi-bin">
    SSLOptions +StdEnvVars
</Directory>

and change to
CustomLog "c:/wamp/logs/ssl_request.log" \
          "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"


Basically look through the conf file and any command that is not commented out, but has a reference to a file or folder
should be changed to reference the WAMPServer folder structure and not 'C:/Apache2....'

Now make sure all these files we have changed are saved, and restart Apache using the wampmanager menus.


First test that the unprotected site is still working.

Then try using your new protected site by adding the 'https://' to the front of the domain name
i.e. `[www.wamphelpers.dev]` without the single quotes of course.



If Apache does not restart you have probably spelt something wrong. Test the configs like so :-

Open a command window
cd \wamp\bin\apache\apache{apache_version}\bin
httpd -t

This will parse all the config files and should give you a file name and a line number where an error has been found.

Fix it and try again.



First access to your site will generate a message page something like this.
This is using FireFox, others will be slightly different, but the concept it the same.



This is because your certificate is not signed by a trusted authority, DONT PANIC, this is supposed to happen.

Click on, 'I Understand the risk' and that will show you a button saying 'Add Exception'
Press the Add Exception button, after checking that the certificates site details are in fact yours,
and you will not see this message again unless you clear the exception list.





BIG NOTE
As of Apache v2.2.12 and OpenSSL v0.9.8j it is now possible to secure more than one site per Apache instance.
This tutorial does not cover that process.
See here for more details:

Here

And here

And here

And like I said at the top, now you need to do some reseach on all the options available in the SSL config and make thing work as you want rather than using the default.

---------------------------------------------------------------------------------------------
(Windows 10 Pro 64bit) (Wampserver 3.1.8 32bit & 64bit)
<Apache versions MULTIPE> <PHP versions MULTIPLE> <MySQL Versions MULTIPLE>
<MariaDB versions MULTIPLE> <phpMyAdmin versions MULTIPLE> <MySQL Workbench 6.3.10>

Read The Manuals Apache -- MySQL -- PHP -- phpMyAdmin
Get your Apache/MySQL/mariaDB/PHP ADDONs here from the WAMPServer alternate Repo
-X-X-X- Backup your MySQL databases regularly Here is How dont regret it later! Yes even when developing -X-X-X-



Edited 1 time(s). Last edit at 11/30/2018 04:24PM by Otomatic.

Options: ReplyQuote
Re: Best way to enable/install SSH with WAMP
Posted by: funkyfrank (179.43.144.---)
Date: August 02, 2015 05:12PM

This will take my days. What a great post! Thank you heaps for putting all this info together! This is really a great effort you show here! Thank you thank you thank you!!

I am asking all this since I am trying to log onto the server through a terminal and that always says use SSH, so I am trying to do this on a local environment.

Following this I realised quickly that the Unix commands are not present on Windows obviously, like the CHMOD for setting file permissions and so on. So I thought installing once of the packages that have parts of the CygWin binaries in them would solve all this.

Been at it all morning only to discover that for example when using WinSSHD there is also no real CHMOD command and although logging into the local server did work over the vhost with the WinSSHD server and client, the commands where not accepted.

So I am back to zero and trying to understand how all this works on Windows..

Nevertheless I will also try out your tutorial and see if I can get working, perhaps with that then I can emulate SSH access to WAMP, use PuTTY and in there then hopefully get commands like CHMOD and such going.

Would you suggest trying all this out on live hosting is better since there they most possibly run the serves on Unix systems and most possibly have the commands ready?

This is a lot to take it but I will hopefully crack it. Loving all this technical stuff!

Thank you again for putting all this information up and taking the time to reply! Great great and simply great!

Do you have a site or do you do freelance work? Do you earn money will all this? I certainly hope so! Let me know if there is a link about you that I could check out please.

Kind Regards

Version of Operating system? Windows 7 Ultimate 64bit
Version of Wamp Server installed? 2.5 32bit
Version of Apache you are running? 2.4.9
Version of MySQL you are running? 5.6.17
Version of PHP you are running? 5.5.12
What colour is your WampManager icon? Green
Host file localhost 127.0.0.1

New to WAMP?
Read this please: [forum.wampserver.com]

Options: ReplyQuote
Re: Best way to enable/install SSH with WAMP
Posted by: RiggsFolly (---.as43234.net)
Date: August 02, 2015 05:38PM

FRANK


YOU DONT NEED ANY OF THAT

You are on a WINDOWS SYSTEM. Use windows.

Also ACCESS RIGHTS are almost never an issue in windows desktop system.

Thats why its a great dev environment and a poor LIVE environment.

---------------------------------------------------------------------------------------------
(Windows 10 Pro 64bit) (Wampserver 3.1.8 32bit & 64bit)
<Apache versions MULTIPE> <PHP versions MULTIPLE> <MySQL Versions MULTIPLE>
<MariaDB versions MULTIPLE> <phpMyAdmin versions MULTIPLE> <MySQL Workbench 6.3.10>

Read The Manuals Apache -- MySQL -- PHP -- phpMyAdmin
Get your Apache/MySQL/mariaDB/PHP ADDONs here from the WAMPServer alternate Repo
-X-X-X- Backup your MySQL databases regularly Here is How dont regret it later! Yes even when developing -X-X-X-

Options: ReplyQuote
Re: Best way to enable/install SSH with WAMP
Posted by: dinacse23@gmail.com (---.113.138.78.static-lvsb.vsnl.net.in)
Date: September 02, 2015 08:29AM

Hi ,
I Followed your steps to configure HTTPS in my server.
also i checked httpd -t in cmd.I got syntax ok.
Then i restarted Apache and Wamp server too.
but wamp is not started.Till it is in Orange icon status.
Pls help me to get solution friends.

Options: ReplyQuote
Re: Best way to enable/install SSH with WAMP
Posted by: RiggsFolly (---.as43234.net)
Date: September 02, 2015 09:47AM

Hi dinacse

Please look in the Apache error log
Please look in the Windows Event Viewer for error messages from Apache
Please look in the ssl_request.log

What do you see?

---------------------------------------------------------------------------------------------
(Windows 10 Pro 64bit) (Wampserver 3.1.8 32bit & 64bit)
<Apache versions MULTIPE> <PHP versions MULTIPLE> <MySQL Versions MULTIPLE>
<MariaDB versions MULTIPLE> <phpMyAdmin versions MULTIPLE> <MySQL Workbench 6.3.10>

Read The Manuals Apache -- MySQL -- PHP -- phpMyAdmin
Get your Apache/MySQL/mariaDB/PHP ADDONs here from the WAMPServer alternate Repo
-X-X-X- Backup your MySQL databases regularly Here is How dont regret it later! Yes even when developing -X-X-X-

Options: ReplyQuote
Re: Best way to enable/install SSH with WAMP
Posted by: LAVenetz (---.dclient.hispeed.ch)
Date: October 03, 2015 11:34AM

Hi
Is this the correct tutorial for Wampserver 2.5, Apache 2.4.9 MySQL : 5.6.17 PHP : 5.5.12 PHPMyAdmin : 4.1.14 ...? I ask because I do not find

<Directory "c:/Apache2/cgi-bin">
SSLOptions +StdEnvVars
</Directory>


and change to

CustomLog "c:/wamp/logs/ssl_request.log" \
"%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"

in "\wamp\bin\apache\apache2.4.9\conf\httpd-ssl.conf". But there is a httpd-ssl.conf in directory "\wamp\bin\apache\apache2.4.9\conf\extra" where I can also not find it.
Regards

Options: ReplyQuote
Re: Best way to enable/install SSH with WAMP
Posted by: RiggsFolly (---.as43234.net)
Date: October 03, 2015 12:55PM

Frank,

Quote

<Directory "c:/Apache2/cgi-bin">
SSLOptions +StdEnvVars
</Directory>


The MEAT in that sandwich is `SSLOptions +StdEnvVars` Look for that in the file suggested and you will find it and hopefully have the nowse to see the minor difference.



Quote

CustomLog "c:/wamp/logs/ssl_request.log" \
"%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"

Ditto: The MEAT in that sandwich is `CustomeLog` Look for that in the file suggested and again you will find it and hopefully have the nowse to see the minor difference.

---------------------------------------------------------------------------------------------
(Windows 10 Pro 64bit) (Wampserver 3.1.8 32bit & 64bit)
<Apache versions MULTIPE> <PHP versions MULTIPLE> <MySQL Versions MULTIPLE>
<MariaDB versions MULTIPLE> <phpMyAdmin versions MULTIPLE> <MySQL Workbench 6.3.10>

Read The Manuals Apache -- MySQL -- PHP -- phpMyAdmin
Get your Apache/MySQL/mariaDB/PHP ADDONs here from the WAMPServer alternate Repo
-X-X-X- Backup your MySQL databases regularly Here is How dont regret it later! Yes even when developing -X-X-X-

Options: ReplyQuote
Re: Best way to enable/install SSH with WAMP
Posted by: LivingThis (---.cm-6-1d.dynamic.ziggo.nl)
Date: April 23, 2016 05:51PM

RiggsFolly Wrote:
-------------------------------------------------------
> 
> Added its name to the
> C:\windows\system32\drivers\etc\hosts
> 
>

.................................................

The hosts file is not in this directory, where can I find it?

Options: ReplyQuote
Re: Best way to enable/install SSH with WAMP
Posted by: Otomatic (Moderator)
Date: April 23, 2016 06:21PM

Hi,

> The hosts file is not in this directory, where can I find it?
It is because you use a 32bit text editor or open file dialog on a W>indows 64 bit.

Read (Note 2) of TROUBLESHOOTING TIPS

------------------------------------------------------------------------------------------------------------
Wampserver 3.1.9 32 bit - Apache 2.4.39 - PHP 7.3.5/7.2.18/7.1.29/7.0.33/5.6.40 - MySQL 5.7.26 - MariaDB 10.3.15
Wampserver 3.1.9 64 bit - Apache 2.4.39 - PHP 7.3.5/7.2.18/7.1.29/7.0.33/5.6.40 - MySQL 5.7.26/8.0.16 - MariaDB 10.3.15
PhPMyadmin 4.8.5 - MysqlDumper 1.24.5
on W10 and W7 Pro 64 bit
Documentation Apache - Documentation PHP - Documentation MySQL - Wampserver install files & addons
« Ce n'est pas parce qu'ils sont nombreux à avoir tort, qu'ils ont forcément raison. Coluche »
« It's not because they are many to be wrong, they are necessarily right. Coluche »

Options: ReplyQuote
Re: Best way to enable/install SSH with WAMP
Posted by: LivingThis (---.cm-6-1d.dynamic.ziggo.nl)
Date: April 23, 2016 07:02PM

Otomatic Wrote:
-------------------------------------------------------
> Hi,
>
> > The hosts file is not in this directory, where
> can I find it?
> It is because you use a 32bit text editor or open
> file dialog on a W>indows 64 bit.
>
> Read (Note 2) of
> [url=http://forum.wampserver.com/read.php?2,134915
> ]TROUBLESHOOTING TIPS[/url]


What do you mean? Do I have to run either windows explorer or notepad ++ as administrator?

I can see the file I found it and opened it in Notepad ++ but I cant save it as the etc directory is not shown while saving.

Options: ReplyQuote
Re: Best way to enable/install SSH with WAMP
Posted by: RiggsFolly (Moderator)
Date: April 23, 2016 10:36PM

You need to be an Administrator to edit that file. Windows protects it.

Simple way to edit the file is to copy it to c:\

Edit it

Copy it back to where you found it.

---------------------------------------------------------------------------------------------
(Windows 10 Pro 64bit) (Wampserver 3.1.8 32bit & 64bit)
<Apache versions MULTIPE> <PHP versions MULTIPLE> <MySQL Versions MULTIPLE>
<MariaDB versions MULTIPLE> <phpMyAdmin versions MULTIPLE> <MySQL Workbench 6.3.10>

Read The Manuals Apache -- MySQL -- PHP -- phpMyAdmin
Get your Apache/MySQL/mariaDB/PHP ADDONs here from the WAMPServer alternate Repo
-X-X-X- Backup your MySQL databases regularly Here is How dont regret it later! Yes even when developing -X-X-X-

Options: ReplyQuote


Sorry, only registered users may post in this forum.