A Julia SFTP Client for exploring the structure and contents of SFTP servers and exchanging files.
This package is based on SFTPClient.jl and builds on Downloads.jl and LibCurl.jl.
SFTP.jl supports username/password as well as certificates for authentication. It provides methods to exchange files with the SFTP server as well as investigate the folder structure and files with methods based on Julia's Filesystem functions. Details can be found in the documentation.
Documentation | Build Status |
---|---|
using SFTP
# Set up client for connection to server
sftp = SFTP.Client("sftp://test.rebex.net/pub/example/", "demo", "password")
# Analyse contents of current path
files=readdir(sftp)
statStructs = statscan(sftp)
# Download contents
download.(sftp, files)
using SFTP
# You can also load file contents to a variable by passing a function to download as first argument
# Note: the function must an AbstractString as parameter for a temporary path of the downloaded file
# Note: the path will be deleted immediately after the contents are saved to the variable
fread(path::AbstractString)::Vector{String} = readlines(path)
array = download(fread, sftp, "data/matrix.csv")
# Certificate authentication works as well
sftp = SFTP.Client("sftp://mysitewhereIhaveACertificate.com", "myuser")
sftp = SFTP.Client("sftp://mysitewhereIhaveACertificate.com", "myuser", "cert.pub", "cert.pem") # Assumes cert.pub and cert.pem is in your current path
# The cert.pem is your certificate (private key), and the cert.pub can be obtained from the private key.
# ssh-keygen -y -f ./cert.pem. Save the output into "cert.pub".