All Projects → tlux → sftp_client

tlux / sftp_client

Licence: MIT license
An Elixir SFTP Client that wraps Erlang's ssh and ssh_sftp.

Programming Languages

elixir
2628 projects

Projects that are alternatives of or similar to sftp client

terraform-aws-sftp
This terraform module is used to create sftp on AWS for S3.
Stars: ✭ 20 (-31.03%)
Mutual labels:  sftp, sftp-client
termscp
🖥 A feature rich terminal UI file transfer and explorer with support for SCP/SFTP/FTP/S3
Stars: ✭ 707 (+2337.93%)
Mutual labels:  sftp, sftp-client
publish-sftp
One-line command to quickly publish resources to a specified server
Stars: ✭ 41 (+41.38%)
Mutual labels:  sftp, sftp-client
dartssh2
SSH and SFTP client written in pure Dart, aiming to be feature-rich as well as easy to use.
Stars: ✭ 63 (+117.24%)
Mutual labels:  sftp, sftp-client
pro.webssh.net
iOS / iPadOS / macOS SSH Client
Stars: ✭ 108 (+272.41%)
Mutual labels:  sftp, sftp-client
Sshj
ssh, scp and sftp for java
Stars: ✭ 2,016 (+6851.72%)
Mutual labels:  sftp, sftp-client
sshtools
Java SSH tools - easier SSH & SFTP in Java
Stars: ✭ 15 (-48.28%)
Mutual labels:  sftp, sftp-client
Filestash
🦄 A modern web client for SFTP, S3, FTP, WebDAV, Git, Minio, LDAP, CalDAV, CardDAV, Mysql, Backblaze, ...
Stars: ✭ 5,231 (+17937.93%)
Mutual labels:  sftp, sftp-client
Vscode Deploy Reloaded
Recoded version of Visual Studio Code extension 'vs-deploy', which provides commands to deploy files to one or more destinations.
Stars: ✭ 129 (+344.83%)
Mutual labels:  sftp
Vscode Remote Workspace
Multi protocol support for handling remote files like local ones in Visual Studio Code.
Stars: ✭ 197 (+579.31%)
Mutual labels:  sftp
Centos Ssh
OpenSSH / Supervisor / EPEL/IUS/SCL Repos - CentOS - Docker image build.
Stars: ✭ 126 (+334.48%)
Mutual labels:  sftp
Wolfssh
wolfSSH is a small, fast, portable SSH implementation, including support for SCP and SFTP.
Stars: ✭ 142 (+389.66%)
Mutual labels:  sftp
Sftpgo
Fully featured and highly configurable SFTP server with optional HTTP, FTP/S and WebDAV support - S3, Google Cloud Storage, Azure Blob
Stars: ✭ 3,534 (+12086.21%)
Mutual labels:  sftp
Etl.net
Mass processing data with a complete ETL for .net developers
Stars: ✭ 129 (+344.83%)
Mutual labels:  sftp
fat ecto
Query mechanism for Ecto
Stars: ✭ 20 (-31.03%)
Mutual labels:  elixir-library
Vs Deploy
Visual Studio Code extension that provides commands to deploy files of a workspace to a destination.
Stars: ✭ 123 (+324.14%)
Mutual labels:  sftp
Drone Cache
A Drone plugin for caching current workspace files between builds to reduce your build times
Stars: ✭ 194 (+568.97%)
Mutual labels:  sftp
File Storage
File storage abstraction for Yii2
Stars: ✭ 116 (+300%)
Mutual labels:  sftp
Premotem
Personal Remote Manager
Stars: ✭ 161 (+455.17%)
Mutual labels:  sftp
Grunt Sftp Deploy
Grunt task for code deployment over sftp
Stars: ✭ 158 (+444.83%)
Mutual labels:  sftp

SFTP Client

Build Status Coverage Status Module Version Hex Docs Total Download License Last Updated

An Elixir SFTP Client that wraps Erlang's ssh and ssh_sftp.

Prerequisites

  • Erlang 20 or greater
  • Elixir 1.8 or greater

Installation

The package can be installed by adding :sftp_client to your list of dependencies in mix.exs:

def deps do
  [
    {:sftp_client, "~> 1.4"}
  ]
end

Usage

There are bang (!) counterparts for almost all available functions.

Connect & Disconnect

To open a new connection to an SFTP server:

{:ok, conn} = SFTPClient.connect(host: "ftp.myhost.com")

Due to a change in OTP 24 that removed automatic public key lookup in the sftp module you may need to define the modify_algorithms option to avoid "Key exchange failed" errors:

{:ok, conn} = SFTPClient.connect(
  host: "ftp.myhost.com",
  modify_algorithms: [
    append: [
      public_key: [:"ssh-rsa"]
    ]
  ]
)

Refer to the docs for SFTPClient.Operations.Connect.connect/1 to find out all available options.

It is strongly recommended to close a connection after your operations have completed:

SFTPClient.disconnect(conn)

For short-lived connections you can also use a function as second argument. After the function body has run or raises, the connection is automatically closed.

SFTPClient.connect([host: "ftp.myhost.com"], fn conn ->
  # Do something with conn
end)

Download

To download a file from the server you can use the following function.

SFTPClient.download_file(conn, "my/remote/dir/file.jpg", "my/dir/local-file.jpg")
# => {:ok, "my/dir/local-file.jpg"}

When the third argument is an existing directory on your file system, the file is downloaded to a file with the same name as the one on the server.

SFTPClient.download_file(conn, "my/remote/dir/image.png", "my/local/dir")
# => {:ok, "my/local/dir/image.png"}

It is also possible to use Streams to download data into a file or memory.

source_stream = SFTPClient.stream_file!(conn, "my/remote/file.jpg")
target_stream = File.stream!("my/local/file.jpg")

source_stream
|> Stream.into(target_stream)
|> Stream.run()

Upload

To upload are file from the file system you can use the following function.

SFTPClient.upload_file(conn, "my/local/dir/file.jpg", "my/remote/dir/file.jpg")
# => {:ok, "my/remote/dir/file.jpg"}

You can also use Streams to upload data. Please make sure to set a proper chunk size or the upload may be very slow.

source_stream = File.stream!("my/local/file.jpg", [], 32_768)
target_stream = SFTPClient.stream_file!(conn, "my/remote/file.jpg")

source_stream
|> Stream.into(target_stream)
|> Stream.run()

List Directory

SFTPClient.list_dir(conn, "my/dir")
# => {:ok, ["my/dir/file_1.jpg", "my/dir/file_2.jpg", ...]}

Create Directory

SFTPClient.make_dir(conn, "my/new/dir")

Note that this operation fails unless the parent directory exists.

Delete

To delete a file:

SFTPClient.delete_file(conn, "my/remote/file.jpg")

To delete a directory:

SFTPClient.delete_dir(conn, "my/remote/dir")

Note that a directory cannot be deleted as long as it still contains files.

Rename

To move/rename a file or directory:

SFTPClient.rename(conn, "my/remote/file.jpg", "my/remote/new-file.jpg")

File Info

You can retrieve meta data about a file from the server such as file size, modification time, file permissions, owner and so on.

SFTPClient.file_info(conn, "my/remote/file.jpg")
# => {:ok, %File.Stat{...}}

Refer to the File.Stat docs for a list of available file information.

Symbolic Links

There are also a couple of functions that handle symlinks.

It is possible to get the target of a symlink.

SFTPClient.read_link(conn, "my/remote/link.jpg")
# => {:ok, "my/remote/file.jpg"}

You can retrieve meta data about symlinks, similar to file_info/2.

SFTPClient.link_info(conn, "my/remote/link.jpg")
# => {:ok, %File.Stat{...}}

And you are able to create symlinks.

SFTPClient.make_link(conn, "my/remote/link.jpg", "my/remote/file.jpg")

License

This library is released under the MIT License. See the LICENSE.md file for further details.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].