Service: SFTP Server - EyevinnOSC/community GitHub Wiki

SFTP Server

SFTP Server (serviceId atmoz-sftp) is a simple, secure file transfer server based on atmoz/sftp, which wraps OpenSSH in a minimal Docker image. In Eyevinn Open Source Cloud (OSC) it is a long-running service instance with up to 10 GiB of storage per instance. License: MIT.

What it can do

  • Create a chroot-jailed user account that can upload and download files over SFTP.
  • Work with any standard SFTP client: FileZilla, sftp, WinSCP, or any programming language with an SSH library.
  • Serve as a secure file drop, an automated upload pipeline target or application-to-application file transfer.

Creating an instance

SFTP Server has no dependencies on other OSC services. Store the password as a service secret with create-service-secret (serviceId atmoz-sftp), then create the instance with create-service-instance, serviceId: "atmoz-sftp":

{
  "name": "mysftp",
  "Username": "upload",
  "Password": "{{secrets.sftppassword}}"
}

Use wait-for-service-ready or get-instance-status, then describe-service-instance for the host and port. With the OSC CLI:

npx -y @osaas/cli create atmoz-sftp mysftp \
  -o Username="upload" \
  -o Password="{{secrets.sftppassword}}"

Options

Option Required Type Meaning
name Yes string Name of the instance. Alphanumeric, at most 20 characters.
Username Yes string Username of the SFTP user account created in the container. Users are chrooted to their home directory at /home/<username>.
Password Yes string, sensitive Password for the SFTP user. Use a strong password, store it as a secret and pass it as {{secrets.NAME}}, as the entire field value.

Using the instance

Connect with any SFTP client using the host and port from describe-service-instance:

sftp -P <PORT> <username>@<host>

For example: sftp -P 10522 [email protected]. After login you land in the user's home directory at /home/<username>/upload/.

In FileZilla use host sftp://<host>, the assigned port, your username and password, and protocol SFTP - SSH File Transfer Protocol.

Node.js (ssh2-sftp-client):

import SftpClient from 'ssh2-sftp-client';

const sftp = new SftpClient();
await sftp.connect({
  host: '<host>',
  port: <PORT>,
  username: '<username>',
  password: '<password>'
});

await sftp.put('./local-file.csv', '/upload/remote-file.csv');
const list = await sftp.list('/upload/');
console.log(list);

await sftp.end();

Python (paramiko):

import paramiko

transport = paramiko.Transport(('<host>', <PORT>))
transport.connect(username='<username>', password='<password>')
sftp = paramiko.SFTPClient.from_transport(transport)

sftp.put('local-file.csv', '/upload/remote-file.csv')
sftp.get('/upload/remote-file.csv', 'downloaded.csv')

sftp.close()
transport.close()

Limitations

  • Storage is limited to 10 GiB per instance.

Resources

⚠️ **GitHub.com Fallback** ⚠️