Rackspace Cloud Files: Upload Files Using Secure FTP (SFTP) Client [ sftp-cloudfs ]

by on October 31, 2012 · 0 comments· LAST UPDATED November 4, 2012

in


I'm using cloud files from Rackspace to store files in cloud. I know how to use ftp client with cloud files, but I would like to use Secure File Transfer Program, sftp on the command line, a true SSH File Transfer Protocol client from the OpenSSH project for security and privacy concern. How do I install sftp-cloudfs under Linux or Unix like operating systems?

You need to use the sftpcloudfs package. This is a SFTP interface to Rackspace Cloud Files and Open Stack Object Storage (Swift). From the project home page:
Tutorial details
DifficultyIntermediate (rss)
Root privilegesYes/No
RequirementsPython, Rackspacec / OpenStack account,
OpenSSH, Pip
Estimated completion timeN/A

This is a SFTP (Secure File Transfer Protocol) interface to Rackspace Cloud Files and OpenStack Object Storage, providing a service that acts as a proxy between a SFTP client and a remote files/storage service. The username/password pair used to open the SFTP session is validated using the authentication service of the files/storage service to get an authentication token.
The communication between the client and the SFTP daemon is encrypted all the time, and the SFTP service supports HTTPS communication with the remote files/storage service.

Install sftp-cloudfs

First, install pip command as described here. Next, type the following pip command to install python package:
$ pip install sftp-cloudfs
Sample outputs:

Downloading/unpacking sftp-cloudfs
  Downloading sftp-cloudfs-0.6.tar.gz
  Running setup.py egg_info for package sftp-cloudfs
Requirement already satisfied (use --upgrade to upgrade): paramiko>=1.7.6 in ./py_virtual/lib/python2.6/site-packages (from sftp-cloudfs)
Requirement already satisfied (use --upgrade to upgrade): python-cloudfiles>=1.7.8 in ./py_virtual/lib/python2.6/site-packages (from sftp-cloudfs)
Requirement already satisfied (use --upgrade to upgrade): python-daemon>=1.5 in ./py_virtual/lib/python2.6/site-packages (from sftp-cloudfs)
Requirement already satisfied (use --upgrade to upgrade): python-memcached>=1.45 in ./py_virtual/lib/python2.6/site-packages (from sftp-cloudfs)
Requirement already satisfied (use --upgrade to upgrade): ftp-cloudfs>=0.19 in ./py_virtual/lib/python2.6/site-packages (from sftp-cloudfs)
Requirement already satisfied (use --upgrade to upgrade): pycrypto>=2.1,!=2.4 in ./py_virtual/lib/python2.6/site-packages (from paramiko>=1.7.6->sftp-cloudfs)
Requirement already satisfied (use --upgrade to upgrade): setuptools in ./py_virtual/lib/python2.6/site-packages (from python-daemon>=1.5->sftp-cloudfs)
Requirement already satisfied (use --upgrade to upgrade): lockfile>=0.9 in ./py_virtual/lib/python2.6/site-packages (from python-daemon>=1.5->sftp-cloudfs)
Requirement already satisfied (use --upgrade to upgrade): pyftpdlib in ./py_virtual/lib/python2.6/site-packages (from ftp-cloudfs>=0.19->sftp-cloudfs)
Installing collected packages: sftp-cloudfs
  Running setup.py install for sftp-cloudfs
    changing mode of build/scripts-2.6/sftpcloudfs from 644 to 755
    changing mode of /home/vivek/py_virtual/bin/sftpcloudfs to 755
Successfully installed sftp-cloudfs
Cleaning up...

Create a host key

You need to create a host key as follows using the ssh-keygen command:
$ mkdir $HOME/.ssh/sftcloudfs
$ ssh-keygen -t rsa -f $HOME/.ssh/sftcloudfs/rsa_key_file

Sample outputs:

Generating public/private rsa key pair.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/vivek/.ssh/sftcloudfs/rsa_key_file.
Your public key has been saved in /home/vivek/.ssh/sftcloudfs/rsa_key_file.pub.
The key fingerprint is:
b1:37:03:54:d3:e6:00:a2:e4:3c:67:16:81:fe:91:52 vivek@wks01
The key's randomart image is:
+--[ RSA 2048]----+
|    ..+.ooo.     |
|   +..E+  ..o    |
|   .=.+.o  +     |
|    o=o  +  .    |
|     o .S +      |
|      .  . o     |
|                 |
|                 |
|                 |
+-----------------+

How do I use sftp-cloudfs?

The syntax is as follows:

 
sftpcloudfs  -k /path/to/rsa_or_dsa_host_file -a http://your-open-cloud-url/path/url
 

For Rackspace USA based cloud file storage account, use:

 
sftpcloudfs -k $HOME/.ssh/sftcloudfs/rsa_key_file -a https://identity.api.rackspacecloud.com/v1.0
 

For Rackspace UK based cloud file storage account, use:

 
sftpcloudfs -k $HOME/.ssh/sftcloudfs/rsa_key_file -a https://lon.auth.api.rackspacecloud.com/v1.0.
 

Verify that sftpcloudfs process is running with the ps command, run:
$ ps aux | grep --color [s]ftpcloudfs
Sample outputs:

vivek    21008  0.1  0.1  55352 10052 ?        S    18:40   0:00 /home/vivek/py_virtual/bin/python /home/vivek/py_virtual/bin/sftpcloudfs -k /home/vivek/.ssh/sftcloudfs/rsa_key_file -a https://identity.api.rackspacecloud.com/v1.0

Make sure the default port 8022 is open:
$ netstat -tulpn | grep :8022
Sample outputs:

(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
tcp        0      0 127.0.0.1:8022          0.0.0.0:*               LISTEN      21008/python

How do I shutdown sftpcloud proxy?

Simply use the kill command send a TERM signal to a process called sftpcloudfs using a PID. First, get a pid, run:
$ ps aux | grep [s]ftpcloudfs
Sample outputs:

vivek    21008  0.0  0.1  55352 10052 ?        S    18:40   0:00 /home/vivek/py_virtual/bin/python /home/vivek/py_virtual/bin/sftpcloudfs -k /home/vivek/.ssh/sftcloudfs/rsa_key_file -a https://identity.api.rackspacecloud.com/v1.0

Kill it:
$ kill 21008
Verify it:
$ ps aux | grep [s]ftpcloudfs

How do I start sftpcloud proxy on different IP and port?

The default bind address is 127.0.0.1, but you can change it using the following syntax. In this example set BIND address to 192.168.1.100, run:

 
sftpcloudfs -b 192.168.1.100 -k $HOME/.ssh/sftcloudfs/rsa_key_file -a https://identity.api.rackspacecloud.com/v1.0
 

The default bind port is 8022, but you can change it using the following syntax. In this example set BIND port to 3000, run:

 
sftpcloudfs -p 3000 -k $HOME/.ssh/sftcloudfs/rsa_key_file -a https://identity.api.rackspacecloud.com/v1.0
 

As usual, you can combine the both -b and -p switches:

 
sftpcloudfs -b 192.168.1.100 -p 3000 -k $HOME/.ssh/sftcloudfs/rsa_key_file -a https://identity.api.rackspacecloud.com/v1.0
 

How do I use sftp client to upload and download files using sftpcloud proxy to Rackspsace cloud files stroage?

Use the default sftp client which is an interactive file transfer program, similar to ftp, which performs all operations over an encrypted ssh transport. The syntax is:

 
sftp -P PORT RACKSPACE-USER@IP-ADDRESS
sftp -P 3000 nixcraft@192.168.1.100
 

Please note you need to use rackspace account API username and password for authentication.

Sample session

sftp -P 8022 nixcraft@127.0.0.1
nixcraft@127.0.0.1's password: HIDDEN-PASSWORD
Connected to 127.0.0.1.
sftp> ls
assets
sftp> mkdir foo
sftp> ls
assets  foo
sftp> lcd /etc
sftp> put resolv.conf 
Uploading resolv.conf to /nixcraft/resolv.conf
resolv.conf
sftp> ls
assets       foo          resolv.conf
sftp> rm resolv.conf 
Removing /nixcraft/resolv.conf
sftp> rmdir foo
sftp> quit

How do I download files from cloud files?

You can use URL to access files in this container via the public internet via cdn url such as follows:

http://8173579aa04ea33f3314-2bd3e6c481b4a486fea8b805a638363d.r25.cf2.rackcdn.com/file.txt

Login to your rackspace cdn account to see CDN enabled url:

Rackspace Cloud Files Akamai CDN URL

Fig.01: Finding Cloud Files Akamai CDN URL via control panel

References
TwitterFacebookGoogle+PDF versionFound an error/typo on this page? Help us!

{ 0 comments… add one now }

Leave a Comment

Tagged as: , , , , , , , ,

Previous Faq:

Next Faq: