SFTP in FileCloud with Linux Scripts

October 20, 2023

Note: this blog post is intended for system and IT administrators who manage FileCloud Server environments. Introduction FileCloud is a hyper-secure platform for storing, managing, and sharing files. Flexible deployment and integration capabilities support enterprises and organizations in extending or even replacing legacy infrastructure to achieve digital transformation. Such initiatives require careful planning and preparation […]

Note: this blog post is intended for system and IT administrators who manage FileCloud Server environments.

Introduction

FileCloud is a hyper-secure platform for storing, managing, and sharing files. Flexible deployment and integration capabilities support enterprises and organizations in extending or even replacing legacy infrastructure to achieve digital transformation. Such initiatives require careful planning and preparation to prevent disruptions and significant adjustments for end users.

A recurring concern we at FileCloud encounter in discussions with our customers revolves around maintaining their current SFTP transfers, particularly those occurring on Linux-based servers. FileCloud employs TLS/SSL channels to secure data in transit; we do not intend to incorporate the SFTP protocol for communication with FileCloud Servers.

However, to simplify our customers' experience, we have developed Linux scripts that can directly replace the existing Linux SFTP client. These scripts facilitate direct file transfers to the FileCloud Server, akin to regular SFTP client usage.

 

Possible Use Cases for FileCloud SFTP

In this blog post, we will outline a precise scenario in which the 'sftp.sh' FileCloud tool facilitates seamless migration to the FileCloud solution, minimizing the need for substantial modifications to the current environment configurations.

Large Network of Linux Firewalls

Let's envision an organization with its headquarters situated in one location and several branch offices scattered across the globe. As part of their connectivity solution, Linux firewalls and VPN servers are operational in various branch offices. These Linux systems regularly upload logs and other files to the central file server located at the headquarters.

The organization's objective is to replace the main file server with an on-premises FileCloud Server – a logical choice in this context. The end-user experience will remain unchanged (using FileCloud Drive) or become highly intuitive through web-based resource access.

However, all prior Linux transfers were based on the SFTP protocol, which is not supported by FileCloud. Initially, this may appear to hinder further migration planning. Fortunately, there's a straightforward solution: replacing the existing SFTP client with the FileCloud-provided 'fcsftp.sh,' which functions almost identically to a regular SFTP client.

Example

Environment Details:

Process Flow Before FileCloud Migration:

Daily transfer:  branchA.company.com --> hqmainsrv01.company.com

Example cron entry on branchA.company.com

[root@branchA ~]# crontab -l
[root@branchA ~] 15 1 * * * /usr/bin/sftp /var/log/syslog
brancha@hqmainsrv01.company.com:/logs/

Process Flow After FileCloud Migration:
Daily transfer:  branchA.company.com --> hqfcsrv01.company.com
Example cron entry on branchA.company.com

[root@branchA ~]# crontab -l
[root@branchA ~] 15 1 * * * /usr/bin/fcsftp.sh /var/log/syslog brancha@hqfcsrv01.company.com:/logs/

Changes to branchA Server:

  1. Upload the FileCloud provided fcsftp.sh script to the branchA server.
    • Location: /usr/bin/
  2. Change the Crontab definition to call the new script instead of the native sftp client.

Internal Functional Server Data Export and Upload

Informational system environments can be intricate, relying on diverse components and servers, interconnected within a network of dependencies. A common example is a solution that gathers data, performs analysis, and eventually generates reports or data sets to share with company employees. Many such batch processes run on infrastructure servers for years; changes to processes that generate and deliver results are usually avoided.

If the automatic transfer relies on SFTP, 'fcsftp.sh' simplifies switching to a new destination, such as the FileCloud Server. The syntax of both SFTP and 'fcsftp.sh' is essentially the same. The 'fcsftp.sh' syntax employs the FileCloud API to directly transport data to the FileCloud instance.

 

Usage

The fcsftp.sh syntax closely resembles the native SFTP Linux command. All possible use cases and syntax combinations will be presented below.

[barni@baCarbonFC SFTP]$ ./fcsftp.sh 
Proper syntax: ./fcsftp.sh <source> <destination>

(<source> and <destination> may represent local file or remote FileCloud servers.)

To provide the password for the FileCloud user, it is possible to store the password in the home directory in the file ~/.fcsftp. If the password is not provided in the command line, the script will read the password from the file (if it exists).

Syntax Examples

Below, we present possible syntax combinations:

Objective: Syntax:
Upload local file to the remote FileCloud server. Full credentials provided in command line:
./fcsftp /home/user1/local_file.txtuser1:my_secret_password@filecloud.my_company.com:/user1/
Upload local file to the remote FileCloud server without providing password in command line. First: Store the password in the file ~/.fcsftp

echo “my_secret_password” > ~/.fcsftp

Then:

./fcsftp /home/user1/local_file.txt user1@filecloud.my_company.com:/user1/

Download remote file to the current folder. Full credentials provided in command line:
./fcsftp user1:my_secret_password@filecloud.my_company.com:/user1/remote_file.txt ./
Download remote file to the current folder (password not provided in command line). First: store the password in the file ~/.fcsftp
echo “my_secret_password” > ~/.fcsftp
Then:
./fcsftp user1@filecloud.my_company.com:/user1/remote_file.txt ./

 

Limitations

Comparing 'fcsftp.sh' to the Linux 'sftp' command reveals certain limitations. The script can handle one file at a time, which implies that wildcards are prohibited. Furthermore, multiple files cannot be specified as script call parameters. If the transfer of multiple files is required, a Linux loop must be employed. An example is provided below:

Upload all *.txt files without presenting password in command line:
for i in `ls *.txt`; do ./fcsftp.sh $i user1@filecloud.my_company.com:/user1/ ;done

 

Conclusion

FileCloud is a powerful, enterprise-grade solution for file storage, management, and sharing. The flexibility of APIs and deployment make it possible to integrate FileCloud with a variety of existing infrastructure scenarios.

We at FileCloud strive to help our customers get work done – by supporting productivity and enabling the use of familiar tools and processes. In this case, though we aren’t planning on offering an SFTP protocol, we are happy to provide this solution for FileCloud administrators to recreate an SFTP-like experience.

To learn more about configuring FileCloud Server with APIs, check out our Developer Guide or reach out to our support team.

 

Article written by Marek Frueauff, Solutions Architect

Edited by Katie Gerhardt, Jr. Product Marketing Manager

By Katie Gerhardt

Jr. Product Marketing Manager