Using SFTP to Transfer Images and Other Files to a Nutanix Storage Container
Several customers have asked if they can post or upload files to the Nutanix storage container, especially when working with automation (like Nutanix Calm) where they might need to store an xml or json file for easy access. Well, there are several ways to do this, but one that has worked well for some of my larger customers is to use SFTP to upload files to the Nutanix storage container. Then, once it the file is on the container, you can use it via the Nutanix Image Service, via NFS or through the option of browsing the ADSF location during the Custom Script option. Below, I’ll show you how to use this feature.
Open CVM Firewall Ports for SFTP
First, open the SFTP port on all CVM’s (required on AOS 5.5 or higher):
allssh modify_firewall -f -o open -i eth0 -p 2222 -a
From the Command Line
When using Linux or a Mac, you can SFTP from the command line. You can also use a command line within Windows, but you will need to download psftp (from the makers of the popular Putty SSH client).
To begin a SFTP session, use the following syntax:
sftp -P 2222 admin@cluster-vip:/container-name
This will SFTP using port 2222 and login with the "admin" user. Replace "cluster-vip" with your cluster virtual IP (VIP) address. Replace "container-name" with the container name as shown in Prism.
This will log into the cluster VIP, change directories to the container-name and then show you a sftp> prompt that is ready to accept commands.

Uploading a File
To upload a file from the local directory, use the "put" command.
In my example below, I’m uploading a file called "testfile.txt" to the container, so I would just use the command:
put testfile.txt

Displaying the Container Files
You can use a simple "ls" command to show a list of files within the container directory.
Here in my example, you can see that the "testfile.txt" was successfully uploaded.

Changing Local (Source) Directories
To change the directory you are in on your local machine, use the "lcd" command.
In my example below, I wanted to change my local source to a different directory than where I was.

Displaying the Local Source Files
You can use the command "lls" to show a list of files within the local (source) directory on your machine. This is helpful in case you don’t know what the filename is that you want to upload.

Example of Using the File Uploaded
A common use-case for uploading a file to the container would be to store a sysprep or cloud-init script file on the container so that you can easily point to it during a VM creation or cloning process. I’ll walk through that process so you can see an example.
The below uses Prism Central, but you could also use Prism Element to accomplish the same thing.
Under the Explore menu, click on "VMs" (1), then find the VM you wish to clone from (2), click on the "Actions" menu (3), then choose "Clone" (4).

Using a Custom Script During a VM Clone
At the very bottom of the Clone VM screen, you will see a check-mark box that says "Custom Script". Go ahead and checkmark the box (1).
Under "ADSF path", type in a forward slash to begin the built-in location browser (2) to help populate the full path of the script file (which you uploaded via SFTP).

Browsing the ADSF Path
By typing in a forward slash under the path name, the system will show you all of the containers available. Once you select the container, then type in a forward slash again, and it will list all of the files available on the container.
In our example below, you can now select the "testfile.txt" file that we previously uploaded via SFTP.
By clicking on the "Save" button, the clone process would continue and then run that customization script automatically once the VM booted up into its operating system.

That’s It For Now!
There are a few other use-cases for uploading a file to the container, but hopefully this has got you started in the right direction. Feel free to leave any feedback in the comments below.