Deploying your code using WinSCP

WinSCP is a popular SFTP and SCP client for Windows, which will allow you to easily manage the files on your application container.

You may obtain WinSCP from http://winscp.net. WinSCP can be either downloaded as an Installation Package or as a Portable Executable (which does not require installation). It is recommended you use the Installation Package as it contains some useful complementary tools (such as puttygen and pagent). This tutorial will assume you have used the Installation Package.

Stage 1 - Setting Up Your Access Key

For security reasons we only allow access to the container using public/private key authentication instead of a password. The remote server you wish to access only needs to know your public key which it uses to encrypt information. Only a person knowing the private key can login to the server and decrypt that information. The private key is never transmitted thus making it difficult to hack.

During container creation you were asked to either upload a public key or to generate a key pair. If you have uploaded a key then we can assume that you are familiar with the topic and can skip to the next stage. Your container already knows your public key so all you need to access it is the private key.

Private Key conversion

When using WinSCP, it is recommended to download your key in PPK format. However, if you have already downloaded a PEM format key, read the following section to learn how to convert it to PPK format. If your key is in PPK format, skip to the next section.

If you have downloaded your key in PEM format then you will first have to convert it using pagent before you can use it with WinSCP. Pagent is part of the WinSCP Installation Package so no installation is required. You should follow the steps below.

  1. Locate the downloaded PEM certificate file and double click on it. After doing so you will get the following notice - click OK to continue
  2. Since the private key allows access to the container it is recommended you protect it with a passphrase. The passphrase will be used to encrypt the key and is not stored anywhere, so if you forget it you will have to regenerate the key. Enter the chosen passphrase into "Key passphrase" and "Confirm passphrase"
  3. private key" to save the key and finish

Stage 2 - Connecting to a saved session

When you first start WinSCP you will see the following screen. This screen allows you to connect to existing "saved sessions" and create new ones. If you have already created a session then just double click on it and start working.

If you are using WinSCP for the first time, click on "New" and continue to the next stage. Don't be alarmed If you see a different screen; some versions of WinSCP detect that there are no saved sessions and will automatically ask you to create a new one - just continue to the next step.

Stage 3 - Creating a new session

If you have not already done so, then click on "New" to create a new session.

You should fill in the details as provided in the "Code" tab of the container platform management interface which can be accessed using the following link https://my.phpcloud.com/#manage-code. When done you can click on "Login" to start working. It is recommended though that you continue reading this guide and perform the next steps.

Mandatory details:

  • Host name: the container's fully qualified domain name (e.g. yourcontainer.my.phpcloud.com)
  • Port number: 22
  • User name: the container's name (e.g. yourcontainer)
  • Password: must be left blank. Filling this in will cause log-in to fail
  • Private key file: The path to the private key file you saved in stage 1

Enable compression

The session to the container can be compressed. This will allow for faster file transfers. Please note that this option does not compress the files but only the data while it is transmitted over the network. If you are connection over a slow connection it is recommended you check "Enable compression".

Choose user interface

WinSCP has a choice of two user interfaces: "Commander" (default) and "Explorer". Users familiar with Norton / Midnight / Total Commander will find the first easier to use. This view is recommended for advanced users. Less experienced users might prefer the "Explorer" interface since it presents you with less information and uses the same user interface and keyboard shortcuts used in Windows Explorer.

Select your preferred interface and click on "Save...".

You have now successfully created a saved session and can click on "Login" to connect. From now on you will only need to double click on your saved session as detailed in "Stage 2" to connect.

Using WinSCP

As mentioned in the previous section WinSCP has two user interfaces: "Explorer" and "Commander". The user interface is selectable in the "Session Details" under the preferences section.

Explorer Interface

You can use the "Explorer" interface much like any other folder in windows. In this view only the container (remote) file system is displayed. In the left you might have a "tree" view of the remote container and in the right you have the files view. You can drag files in and out of the container, cut/paste and use regular windows keyboard shortcuts.

Commander Interface

In this interface you are displayed with two panels: in the left is your local file system (the one on your computer), in the right is the container's (remote) file system.

You can drag files between panels to move them around. You can also drag and drop files to and from your desktop or other open "Explorer" directories.

All you need to do to upload content is to drag your files to the applications/<app name>/public folder in the right panel. Please note that keyboard shortcuts are different from other windows programs. Take some time to read the full manual to get familiar with them.

Modifying file and directory permissions

The containers use the UNIX permissions structure. In our setup your user is allowed to upload files to the system but your PHP application is only allowed to read them. Some PHP applications require write access be granted to certain directories. To grant this access you will have to:

  1. Right click on the file or folder.
  2. Check the "W" selection box in the "Group" line. You can optionally also check "Set group, owner and permissions recursively" to apply the change to sub-directories. When done click on "OK". This operation might take some time - especially if your application has many files.

Further reading

This tutorial should have provided you the basic knowledge you require to upload and manage files on your container. To learn how to user WinSCP's advanced features it is recommended you read the full documentation. This can be found under the "Help" menu and also in http://winscp.net/eng/docs/start.