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 | |
---|---|
Difficulty | Intermediate (rss) |
Root privileges | Yes/No |
Requirements | Python, Rackspacec / OpenStack account, OpenSSH, Pip |
Time | N/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:
References
- sftp-cloudfs
- Rackspace (cp link)
- Openstack
🐧 Get the latest tutorials on Linux, Open Source & DevOps via:
- RSS feed or Weekly email newsletter
- Share on Twitter • Facebook • 2 comments... add one ↓
Category | List of Unix and Linux commands |
---|---|
File Management | cat |
Firewall | Alpine Awall • CentOS 8 • OpenSUSE • RHEL 8 • Ubuntu 16.04 • Ubuntu 18.04 • Ubuntu 20.04 |
Network Utilities | dig • host • ip • nmap |
OpenVPN | CentOS 7 • CentOS 8 • Debian 10 • Debian 8/9 • Ubuntu 18.04 • Ubuntu 20.04 |
Package Manager | apk • apt |
Processes Management | bg • chroot • cron • disown • fg • jobs • killall • kill • pidof • pstree • pwdx • time |
Searching | grep • whereis • which |
User Information | groups • id • lastcomm • last • lid/libuser-lid • logname • members • users • whoami • who • w |
WireGuard VPN | Alpine • CentOS 8 • Debian 10 • Firewall • Ubuntu 20.04 |
Is this means cloud account and API key which is present in Account setting for RackSpace Cloud for the “sftp -P PORT RACKSPACE-USER@IP-ADDRESS”?
And what would be IP address?
The IP address is the local address of your sftp-cloudfs proxy that you started just a few moments earlier.