The `sftp` command line tool which is included on Linux, Mac OS X and other systems as part
of the OpenSSH suite, can be used to demonstrate connecting to your application container.
Connecting to your application container
Assuming that your container name is `mycontainer`, and that you have saved your PEM encoded private
key in `~/keys/zendcloud-mycontainer.pem`, you will use the following command to connect to your
container using SFTP:
$ sftp -o IdentityFile=~/keys/zendcloud-mycontainer.pem \
mycontainer@mycontainer.my.phpcloud.com
The `-o IdentityFile=...` option allows you to specify the path to your PEM encoded private key file.
On your first attempt to connect to your container using SFTP, you will be asked to approve
accepting the host's RSA fingerprint to the list of known hosts:
The authenticity of host 'mycontainer.my.phpcloud.com (10.20.30.40)' can't be established. RSA key fingerprint is 8f:e5:4c:82:9c:cb:7e:ce:9f:1c:ec:d7:45:04:34:46. Are you sure you want to continue connecting (yes/no)?
This is a regular procedure when connecting to remote servers using SSH based protocols - you should
type `yes` to connect. Future connections to the same container should not prompt this
question. If all parameters were provided correctly, you will now be connected
to the server, and will be presented with the sftp prompt:
sftp>
Working in the sftp Shell
The SFTP shell allows you to interactively manage files and directories on the remote server, over a secure
connection. Many of the commands resemble common UNIX shell commands, so those accustomed to using the
command line in Linux, Mac OS X or other similar systems will feel at home.
For example, to get a list of files in the current directory, use the `ls` command,
or even `ls -l` to get a more detailed listing of files.
The following set of commands demonstrate how you can change into your public document root directory,
and copy a file named 'hello.php' from your local machine to the remote machine:
sftp> ls -l drwxr-x--- 3 1005 1005 4096 Apr 13 10:47 mycontainer sftp> cd mycontainer/applications/container-root/public sftp> !ls -l total 1 -rw-r--r-- 1 shahar staff 30 Apr 28 11:05 hello.php sftp> put hello.php Uploading hello.php to /mycontainer/applications/container-root/hello.php hello.php 100% 30 0.0KB/s 00:00 sftp>
Here is a quick overview of these commands:
- ls -l
- Get a detailed listing of the files in the current directory
- cd mycontainer/applications/container-root/public
- Change into the mycontainer/applications/container-root/public directory (a directory relative to the current directory)
- !ls -l
- Run the
`ls -l`command in the local machine - this gives a listing of
files in the current local directory. Any command starting with '!' (an exclamation mark) will be
executed locally - put hello.php
- Copy the local file
`hello.php`from the current directory in the local machine to
the current directory in the remote machine
This shows some basic usage of the `sfp` interactive prompt. To learn more, you can type '?' or 'help'
at any time to get a list of commands with some usage information.

