diff --git a/dev/.documenter-siteinfo.json b/dev/.documenter-siteinfo.json index 3659cc3..31906e9 100644 --- a/dev/.documenter-siteinfo.json +++ b/dev/.documenter-siteinfo.json @@ -1 +1 @@ -{"documenter":{"julia_version":"1.9.4","generation_timestamp":"2023-12-04T10:39:35","documenter_version":"1.2.1"}} \ No newline at end of file +{"documenter":{"julia_version":"1.9.4","generation_timestamp":"2023-12-16T10:03:57","documenter_version":"1.2.1"}} \ No newline at end of file diff --git a/dev/index.html b/dev/index.html index 77f0766..05d780b 100644 --- a/dev/index.html +++ b/dev/index.html @@ -21,4 +21,4 @@ sftp = SFTP("sftp://mysitewhereIhaveACertificate.com", "myuser", "cert.pub", "cert.pem") # The cert.pem is your certificate (private key), and the cert.pub can be obtained from the private # key as following: ssh-keygen -y -f ./cert.pem. Save the output into "cert.pub". - + diff --git a/dev/reference/index.html b/dev/reference/index.html index 2ceb480..551be2f 100644 --- a/dev/reference/index.html +++ b/dev/reference/index.html @@ -1,11 +1,11 @@ SFTPClient API Documentation · Julia SFTPClient Documentation

SFTPClient API Documentation

Base.Filesystem.mvMethod

mv( sftp::SFTP, oldname::AbstractString, newname::AbstractString; )

Move, i.e., rename the file.

source
Base.Filesystem.readdirFunction

readdir(sftp::SFTP, join::Bool = false, sort::Bool = true)

Reads the current directory. Returns a vector of Strings just like the regular readdir function.

source
Base.Filesystem.mvMethod

mv( sftp::SFTP, oldname::AbstractString, newname::AbstractString; )

Move, i.e., rename the file.

source
Base.Filesystem.readdirFunction

readdir(sftp::SFTP, join::Bool = false, sort::Bool = true)

Reads the current directory. Returns a vector of Strings just like the regular readdir function.

source
SFTPClient.downloadFunction

SFTP.download( sftp::SFTP, file_name::AbstractString, output = tempname();downloadDir::Union{String, Nothing}=nothing)

 Download a file. You can download it and use it directly, or save it to a file. 
+Remove (delete) the file
source
SFTPClient.downloadFunction

SFTP.download( sftp::SFTP, file_name::AbstractString, output = tempname();downloadDir::Union{String, Nothing}=nothing)

 Download a file. You can download it and use it directly, or save it to a file. 
  Specify downloadDir if you want to save downloaded files. You can also use broadcasting.
 Example:
 
@@ -15,6 +15,6 @@
 SFTPClient.download.(sftp, files, downloadDir=downloadDir)
 
 You can also use it like this:
-df=DataFrame(CSV.File(SFTPClient.download(sftp, "/mydir/test.csv")))
source
SFTPClient.rmdirMethod
rmdir(sftp::SFTP, dir_name::AbstractString)
+df=DataFrame(CSV.File(SFTPClient.download(sftp, "/mydir/test.csv")))
source
SFTPClient.sftpstatMethod

sftpstat(sftp::SFTP)

Like Julia stat, but returns a Vector of SFTPStatStructs. Note that you can only run this on directories. Can be used for checking if a file was modified, and much more.

source
SFTPClient.uploadMethod

upload(sftp::SFTP, file_name::AbstractString)

Upload (put) a file to the server. Broadcasting can be used too.

files=readdir() upload.(sftp,files)

source
SFTPClient.SFTPMethod

function SFTP(url::AbstractString, username::AbstractString;disableverifypeer=false, disableverifyhost=false)

Creates a new SFTP client using certificate authentication, and keys in the files specified

sftp = SFTP("sftp://mysitewhereIhaveACertificate.com", "myuser", "test.pub", "test.pem")

source
SFTPClient.SFTPMethod

function SFTP(url::AbstractString, username::AbstractString, password::AbstractString;createknownhostsentry=true, disableverifypeer=false, disableverify_host=false)

Creates a new SFTP Client: url: The url to connect to, e.g., sftp://mysite.com username: The username to use password: The users password createknownhosts_entry: Automatically create an entry in known hosts

Example: sftp = SFTP("sftp://test.rebex.net", "demo", "password")

source
SFTPClient.SFTPMethod

function SFTP(url::AbstractString, username::AbstractString;disableverifypeer=false, disableverifyhost=false)

Creates a new SFTP client using certificate authentication.

sftp = SFTP("sftp://mysitewhereIhaveACertificate.com", "myuser")

Note! You must provide the username for this to work.

Before using this method, you must set up your certificates in ~/.ssh/idrsa and ~/.ssh/idrsa.pub

Of course, the host need to be in the known_hosts file as well.

Test using your local client first: ssh myuser@mysitewhereIhaveACertificate.com

See other method if you want to use files not in ~/ssh/

source
+Remove (delete) the directorysource
SFTPClient.sftpstatMethod

sftpstat(sftp::SFTP)

Like Julia stat, but returns a Vector of SFTPStatStructs. Note that you can only run this on directories. Can be used for checking if a file was modified, and much more.

source
SFTPClient.uploadMethod

upload(sftp::SFTP, file_name::AbstractString)

Upload (put) a file to the server. Broadcasting can be used too.

files=readdir() upload.(sftp,files)

source
SFTPClient.SFTPMethod

function SFTP(url::AbstractString, username::AbstractString;disableverifypeer=false, disableverifyhost=false)

Creates a new SFTP client using certificate authentication, and keys in the files specified

sftp = SFTP("sftp://mysitewhereIhaveACertificate.com", "myuser", "test.pub", "test.pem")

source
SFTPClient.SFTPMethod

function SFTP(url::AbstractString, username::AbstractString, password::AbstractString;createknownhostsentry=true, disableverifypeer=false, disableverify_host=false)

Creates a new SFTP Client: url: The url to connect to, e.g., sftp://mysite.com username: The username to use password: The users password createknownhosts_entry: Automatically create an entry in known hosts

Example: sftp = SFTP("sftp://test.rebex.net", "demo", "password")

source
SFTPClient.SFTPMethod

function SFTP(url::AbstractString, username::AbstractString;disableverifypeer=false, disableverifyhost=false)

Creates a new SFTP client using certificate authentication.

sftp = SFTP("sftp://mysitewhereIhaveACertificate.com", "myuser")

Note! You must provide the username for this to work.

Before using this method, you must set up your certificates in ~/.ssh/idrsa and ~/.ssh/idrsa.pub

Of course, the host need to be in the known_hosts file as well.

Test using your local client first: ssh myuser@mysitewhereIhaveACertificate.com

See other method if you want to use files not in ~/ssh/

source
diff --git a/dev/search_index.js b/dev/search_index.js index 1722d54..170bffd 100644 --- a/dev/search_index.js +++ b/dev/search_index.js @@ -1,3 +1,3 @@ var documenterSearchIndex = {"docs": -[{"location":"troubleshooting/#Troubleshooting","page":"Troubleshooting","title":"Troubleshooting","text":"","category":"section"},{"location":"troubleshooting/","page":"Troubleshooting","title":"Troubleshooting","text":"If you get: RequestError: Failure establishing ssh session: -5, Unable to exchange encryption keys while requesting... Try and upgrade to Julia 1.9.4. It seems to be a bug in an underlying library.","category":"page"},{"location":"troubleshooting/","page":"Troubleshooting","title":"Troubleshooting","text":"If it does not work, check your known_hosts file in your .ssh directory. ED25519 keys do not seem to work.","category":"page"},{"location":"troubleshooting/","page":"Troubleshooting","title":"Troubleshooting","text":"Use the ssh-keyscan tool: From command line, execute: ssh-keyscan [hostname]. Add the ecdsa-sha2-nistp256 line to your knownhosts file. This file is located in your .ssh-directory. This is directory is located in C:\\Users\\{youruser}\\.ssh on Windows and ~/.ssh on Linux.","category":"page"},{"location":"troubleshooting/","page":"Troubleshooting","title":"Troubleshooting","text":"___Note: Setting up certificate authentication___","category":"page"},{"location":"troubleshooting/","page":"Troubleshooting","title":"Troubleshooting","text":"To set up certificate authentication, create the certificates in the ~/.ssh/idrsa and ~/.ssh/idrsa.pub files. On Windows these are located in C:\\Users\\{your user}\\.ssh. ","category":"page"},{"location":"troubleshooting/","page":"Troubleshooting","title":"Troubleshooting","text":"Then use the function sftp = SFTP(\"sftp://mysitewhereIhaveACertificate.com\", \"myuser\") to create a SFTP type.","category":"page"},{"location":"troubleshooting/","page":"Troubleshooting","title":"Troubleshooting","text":"Example files","category":"page"},{"location":"troubleshooting/","page":"Troubleshooting","title":"Troubleshooting","text":"___in \"known_hosts\"___ mysitewhereIhaveACertificate.com ssh-rsa sdsadxcvacvljsdflsajflasjdfasldjfsdlfjsldfj","category":"page"},{"location":"troubleshooting/","page":"Troubleshooting","title":"Troubleshooting","text":"___in \"id_rsa\"___","category":"page"},{"location":"troubleshooting/","page":"Troubleshooting","title":"Troubleshooting","text":"––-BEGIN RSA PRIVATE KEY––- ..... cu1sTszTVkP5/rL3CbI+9rgsuCwM67k3DiH4JGOzQpMThPvolCg=","category":"page"},{"location":"troubleshooting/","page":"Troubleshooting","title":"Troubleshooting","text":"––-END RSA PRIVATE KEY––-","category":"page"},{"location":"troubleshooting/","page":"Troubleshooting","title":"Troubleshooting","text":"___in id_rsa.pub___ ssh-rsa AAAAB3...SpjX/4t Comment here","category":"page"},{"location":"troubleshooting/","page":"Troubleshooting","title":"Troubleshooting","text":"After setting up the files, test using your local sftp client:","category":"page"},{"location":"troubleshooting/","page":"Troubleshooting","title":"Troubleshooting","text":"ssh myuser@mysitewhereIhaveACertificate.com","category":"page"},{"location":"troubleshooting/","page":"Troubleshooting","title":"Troubleshooting","text":"___Known bugs___","category":"page"},{"location":"troubleshooting/","page":"Troubleshooting","title":"Troubleshooting","text":"Currently some operations, e.g. mv fails if the remote path has a space or special character in it. It works for files having space in them, but not for directories having space in them. ","category":"page"},{"location":"reference/#SFTPClient-API-Documentation","page":"SFTPClient API Documentation","title":"SFTPClient API Documentation","text":"","category":"section"},{"location":"reference/","page":"SFTPClient API Documentation","title":"SFTPClient API Documentation","text":"Modules = [SFTPClient]\nOrder = [:function, :type]","category":"page"},{"location":"reference/#Base.Filesystem.cd-Tuple{SFTP, AbstractString}","page":"SFTPClient API Documentation","title":"Base.Filesystem.cd","text":"cd(sftp::SFTP, dir::AbstractString)\n\nChange the directory for the SFTP client.\n\n\n\n\n\n","category":"method"},{"location":"reference/#Base.Filesystem.mkdir-Tuple{SFTP, AbstractString}","page":"SFTPClient API Documentation","title":"Base.Filesystem.mkdir","text":"mkdir(sftp::SFTP, dir::AbstractString)\n\nCreate a directory\n\n\n\n\n\n","category":"method"},{"location":"reference/#Base.Filesystem.mv-Tuple{SFTP, AbstractString, AbstractString}","page":"SFTPClient API Documentation","title":"Base.Filesystem.mv","text":"mv( sftp::SFTP, oldname::AbstractString, newname::AbstractString; )\n\nMove, i.e., rename the file. \n\n\n\n\n\n","category":"method"},{"location":"reference/#Base.Filesystem.readdir","page":"SFTPClient API Documentation","title":"Base.Filesystem.readdir","text":"readdir(sftp::SFTP, join::Bool = false, sort::Bool = true)\n\nReads the current directory. Returns a vector of Strings just like the regular readdir function.\n\n\n\n\n\n","category":"function"},{"location":"reference/#Base.Filesystem.rm-Tuple{SFTP, AbstractString}","page":"SFTPClient API Documentation","title":"Base.Filesystem.rm","text":"rm(sftp::SFTP, file_name::AbstractString)\n\nRemove (delete) the file\n\n\n\n\n\n","category":"method"},{"location":"reference/#SFTPClient.download","page":"SFTPClient API Documentation","title":"SFTPClient.download","text":"SFTP.download( sftp::SFTP, file_name::AbstractString, output = tempname();downloadDir::Union{String, Nothing}=nothing)\n\n Download a file. You can download it and use it directly, or save it to a file. \n Specify downloadDir if you want to save downloaded files. You can also use broadcasting.\nExample:\n\nsftp = SFTP(\"sftp://test.rebex.net/pub/example/\", \"demo\", \"password\")\nfiles=readdir(sftp)\ndownloadDir=\"/tmp\"\nSFTPClient.download.(sftp, files, downloadDir=downloadDir)\n\nYou can also use it like this:\ndf=DataFrame(CSV.File(SFTPClient.download(sftp, \"/mydir/test.csv\")))\n\n\n\n\n\n","category":"function"},{"location":"reference/#SFTPClient.rmdir-Tuple{SFTP, AbstractString}","page":"SFTPClient API Documentation","title":"SFTPClient.rmdir","text":"rmdir(sftp::SFTP, dir_name::AbstractString)\n\nRemove (delete) the directory\n\n\n\n\n\n","category":"method"},{"location":"reference/#SFTPClient.sftpstat-Tuple{SFTP}","page":"SFTPClient API Documentation","title":"SFTPClient.sftpstat","text":"sftpstat(sftp::SFTP)\n\nLike Julia stat, but returns a Vector of SFTPStatStructs. Note that you can only run this on directories. Can be used for checking if a file was modified, and much more.\n\n\n\n\n\n","category":"method"},{"location":"reference/#SFTPClient.upload-Tuple{SFTP, AbstractString}","page":"SFTPClient API Documentation","title":"SFTPClient.upload","text":"upload(sftp::SFTP, file_name::AbstractString)\n\nUpload (put) a file to the server. Broadcasting can be used too. \n\nfiles=readdir() upload.(sftp,files)\n\n\n\n\n\n","category":"method"},{"location":"reference/#SFTPClient.SFTP-NTuple{4, AbstractString}","page":"SFTPClient API Documentation","title":"SFTPClient.SFTP","text":"function SFTP(url::AbstractString, username::AbstractString;disableverifypeer=false, disableverifyhost=false)\n\nCreates a new SFTP client using certificate authentication, and keys in the files specified\n\nsftp = SFTP(\"sftp://mysitewhereIhaveACertificate.com\", \"myuser\", \"test.pub\", \"test.pem\")\n\n\n\n\n\n","category":"method"},{"location":"reference/#SFTPClient.SFTP-Tuple{AbstractString, AbstractString, AbstractString}","page":"SFTPClient API Documentation","title":"SFTPClient.SFTP","text":"function SFTP(url::AbstractString, username::AbstractString, password::AbstractString;createknownhostsentry=true, disableverifypeer=false, disableverify_host=false)\n\nCreates a new SFTP Client: url: The url to connect to, e.g., sftp://mysite.com username: The username to use password: The users password createknownhosts_entry: Automatically create an entry in known hosts\n\nExample: sftp = SFTP(\"sftp://test.rebex.net\", \"demo\", \"password\")\n\n\n\n\n\n","category":"method"},{"location":"reference/#SFTPClient.SFTP-Tuple{AbstractString, AbstractString}","page":"SFTPClient API Documentation","title":"SFTPClient.SFTP","text":"function SFTP(url::AbstractString, username::AbstractString;disableverifypeer=false, disableverifyhost=false)\n\nCreates a new SFTP client using certificate authentication. \n\nsftp = SFTP(\"sftp://mysitewhereIhaveACertificate.com\", \"myuser\")\n\nNote! You must provide the username for this to work. \n\nBefore using this method, you must set up your certificates in ~/.ssh/idrsa and ~/.ssh/idrsa.pub\n\nOf course, the host need to be in the known_hosts file as well. \n\nTest using your local client first: ssh myuser@mysitewhereIhaveACertificate.com\n\nSee other method if you want to use files not in ~/ssh/\n\n\n\n\n\n","category":"method"},{"location":"#Julia-SFTP-Client","page":"Julia SFTP Client","title":"Julia SFTP Client","text":"","category":"section"},{"location":"","page":"Julia SFTP Client","title":"Julia SFTP Client","text":"An SFTP Client for Julia.","category":"page"},{"location":"","page":"Julia SFTP Client","title":"Julia SFTP Client","text":"A julia package for communicating with SFTP Servers, supporting username and password, or certificate authentication. ","category":"page"},{"location":"#SFTPClient-Features","page":"Julia SFTP Client","title":"SFTPClient Features","text":"","category":"section"},{"location":"","page":"Julia SFTP Client","title":"Julia SFTP Client","text":"- readdir\n- download\n- upload \n- cd\n- rm \n- rmdir\n- mkdir\n- mv\n- sftpstat (like stat, but more limited)","category":"page"},{"location":"#SFTPClient-Installation","page":"Julia SFTP Client","title":"SFTPClient Installation","text":"","category":"section"},{"location":"","page":"Julia SFTP Client","title":"Julia SFTP Client","text":"Install by running:","category":"page"},{"location":"","page":"Julia SFTP Client","title":"Julia SFTP Client","text":"import Pkg;Pkg.add(\"SFTPClient\")","category":"page"},{"location":"#SFTPClient-Examples","page":"Julia SFTP Client","title":"SFTPClient Examples","text":"","category":"section"},{"location":"","page":"Julia SFTP Client","title":"Julia SFTP Client","text":"\n using SFTPClient\n sftp = SFTP(\"sftp://test.rebex.net/pub/example/\", \"demo\", \"password\")\n files=readdir(sftp)\n # On Windows, replace this with an appropriate path\n downloadDir=\"/tmp/\"\n SFTPClient.download.(sftp, files, downloadDir=downloadDir)\n","category":"page"},{"location":"","page":"Julia SFTP Client","title":"Julia SFTP Client","text":" #You can also use it like this\n df=DataFrame(CSV.File(SFTPClient.download(sftp, \"/mydir/test.csv\")))\n\n # For certificate authentication, you can do this (since 0.3.8)\n sftp = SFTP(\"sftp://mysitewhereIhaveACertificate.com\", \"myuser\", \"cert.pub\", \"cert.pem\")\n \n # The cert.pem is your certificate (private key), and the cert.pub can be obtained from the private # key as following: ssh-keygen -y -f ./cert.pem. Save the output into \"cert.pub\". \n","category":"page"}] +[{"location":"troubleshooting/#Troubleshooting","page":"Troubleshooting","title":"Troubleshooting","text":"","category":"section"},{"location":"troubleshooting/","page":"Troubleshooting","title":"Troubleshooting","text":"If you get: RequestError: Failure establishing ssh session: -5, Unable to exchange encryption keys while requesting... Try and upgrade to Julia 1.9.4. It seems to be a bug in an underlying library.","category":"page"},{"location":"troubleshooting/","page":"Troubleshooting","title":"Troubleshooting","text":"If it does not work, check your known_hosts file in your .ssh directory. ED25519 keys do not seem to work.","category":"page"},{"location":"troubleshooting/","page":"Troubleshooting","title":"Troubleshooting","text":"Use the ssh-keyscan tool: From command line, execute: ssh-keyscan [hostname]. Add the ecdsa-sha2-nistp256 line to your knownhosts file. This file is located in your .ssh-directory. This is directory is located in C:\\Users\\{youruser}\\.ssh on Windows and ~/.ssh on Linux.","category":"page"},{"location":"troubleshooting/","page":"Troubleshooting","title":"Troubleshooting","text":"___Note: Setting up certificate authentication___","category":"page"},{"location":"troubleshooting/","page":"Troubleshooting","title":"Troubleshooting","text":"To set up certificate authentication, create the certificates in the ~/.ssh/idrsa and ~/.ssh/idrsa.pub files. On Windows these are located in C:\\Users\\{your user}\\.ssh. ","category":"page"},{"location":"troubleshooting/","page":"Troubleshooting","title":"Troubleshooting","text":"Then use the function sftp = SFTP(\"sftp://mysitewhereIhaveACertificate.com\", \"myuser\") to create a SFTP type.","category":"page"},{"location":"troubleshooting/","page":"Troubleshooting","title":"Troubleshooting","text":"Example files","category":"page"},{"location":"troubleshooting/","page":"Troubleshooting","title":"Troubleshooting","text":"___in \"known_hosts\"___ mysitewhereIhaveACertificate.com ssh-rsa sdsadxcvacvljsdflsajflasjdfasldjfsdlfjsldfj","category":"page"},{"location":"troubleshooting/","page":"Troubleshooting","title":"Troubleshooting","text":"___in \"id_rsa\"___","category":"page"},{"location":"troubleshooting/","page":"Troubleshooting","title":"Troubleshooting","text":"––-BEGIN RSA PRIVATE KEY––- ..... cu1sTszTVkP5/rL3CbI+9rgsuCwM67k3DiH4JGOzQpMThPvolCg=","category":"page"},{"location":"troubleshooting/","page":"Troubleshooting","title":"Troubleshooting","text":"––-END RSA PRIVATE KEY––-","category":"page"},{"location":"troubleshooting/","page":"Troubleshooting","title":"Troubleshooting","text":"___in id_rsa.pub___ ssh-rsa AAAAB3...SpjX/4t Comment here","category":"page"},{"location":"troubleshooting/","page":"Troubleshooting","title":"Troubleshooting","text":"After setting up the files, test using your local sftp client:","category":"page"},{"location":"troubleshooting/","page":"Troubleshooting","title":"Troubleshooting","text":"ssh myuser@mysitewhereIhaveACertificate.com","category":"page"},{"location":"reference/#SFTPClient-API-Documentation","page":"SFTPClient API Documentation","title":"SFTPClient API Documentation","text":"","category":"section"},{"location":"reference/","page":"SFTPClient API Documentation","title":"SFTPClient API Documentation","text":"Modules = [SFTPClient]\nOrder = [:function, :type]","category":"page"},{"location":"reference/#Base.Filesystem.cd-Tuple{SFTP, AbstractString}","page":"SFTPClient API Documentation","title":"Base.Filesystem.cd","text":"cd(sftp::SFTP, dir::AbstractString)\n\nChange the directory for the SFTP client.\n\n\n\n\n\n","category":"method"},{"location":"reference/#Base.Filesystem.filemode-Tuple{SFTPStatStruct}","page":"SFTPClient API Documentation","title":"Base.Filesystem.filemode","text":"Base.isdir(st::SFTPStatStruct) \n\nGet the filemode of the directory\n\n\n\n\n\n","category":"method"},{"location":"reference/#Base.Filesystem.isdir-Tuple{SFTPStatStruct}","page":"SFTPClient API Documentation","title":"Base.Filesystem.isdir","text":"Base.isdir(st::SFTPStatStruct) \n\nTest if st is a directory\n\n\n\n\n\n","category":"method"},{"location":"reference/#Base.Filesystem.isfile-Tuple{SFTPStatStruct}","page":"SFTPClient API Documentation","title":"Base.Filesystem.isfile","text":"Base.isfile(st::SFTPStatStruct) \n\nTest if st is a file\n\n\n\n\n\n","category":"method"},{"location":"reference/#Base.Filesystem.mkdir-Tuple{SFTP, AbstractString}","page":"SFTPClient API Documentation","title":"Base.Filesystem.mkdir","text":"mkdir(sftp::SFTP, dir::AbstractString)\n\nCreate a directory\n\n\n\n\n\n","category":"method"},{"location":"reference/#Base.Filesystem.mv-Tuple{SFTP, AbstractString, AbstractString}","page":"SFTPClient API Documentation","title":"Base.Filesystem.mv","text":"mv( sftp::SFTP, oldname::AbstractString, newname::AbstractString; )\n\nMove, i.e., rename the file. \n\n\n\n\n\n","category":"method"},{"location":"reference/#Base.Filesystem.readdir","page":"SFTPClient API Documentation","title":"Base.Filesystem.readdir","text":"readdir(sftp::SFTP, join::Bool = false, sort::Bool = true)\n\nReads the current directory. Returns a vector of Strings just like the regular readdir function.\n\n\n\n\n\n","category":"function"},{"location":"reference/#Base.Filesystem.rm-Tuple{SFTP, AbstractString}","page":"SFTPClient API Documentation","title":"Base.Filesystem.rm","text":"rm(sftp::SFTP, file_name::AbstractString)\n\nRemove (delete) the file\n\n\n\n\n\n","category":"method"},{"location":"reference/#SFTPClient.download","page":"SFTPClient API Documentation","title":"SFTPClient.download","text":"SFTP.download( sftp::SFTP, file_name::AbstractString, output = tempname();downloadDir::Union{String, Nothing}=nothing)\n\n Download a file. You can download it and use it directly, or save it to a file. \n Specify downloadDir if you want to save downloaded files. You can also use broadcasting.\nExample:\n\nsftp = SFTP(\"sftp://test.rebex.net/pub/example/\", \"demo\", \"password\")\nfiles=readdir(sftp)\ndownloadDir=\"/tmp\"\nSFTPClient.download.(sftp, files, downloadDir=downloadDir)\n\nYou can also use it like this:\ndf=DataFrame(CSV.File(SFTPClient.download(sftp, \"/mydir/test.csv\")))\n\n\n\n\n\n","category":"function"},{"location":"reference/#SFTPClient.rmdir-Tuple{SFTP, AbstractString}","page":"SFTPClient API Documentation","title":"SFTPClient.rmdir","text":"rmdir(sftp::SFTP, dir_name::AbstractString)\n\nRemove (delete) the directory\n\n\n\n\n\n","category":"method"},{"location":"reference/#SFTPClient.sftpstat-Tuple{SFTP}","page":"SFTPClient API Documentation","title":"SFTPClient.sftpstat","text":"sftpstat(sftp::SFTP)\n\nLike Julia stat, but returns a Vector of SFTPStatStructs. Note that you can only run this on directories. Can be used for checking if a file was modified, and much more.\n\n\n\n\n\n","category":"method"},{"location":"reference/#SFTPClient.upload-Tuple{SFTP, AbstractString}","page":"SFTPClient API Documentation","title":"SFTPClient.upload","text":"upload(sftp::SFTP, file_name::AbstractString)\n\nUpload (put) a file to the server. Broadcasting can be used too. \n\nfiles=readdir() upload.(sftp,files)\n\n\n\n\n\n","category":"method"},{"location":"reference/#SFTPClient.SFTP-NTuple{4, AbstractString}","page":"SFTPClient API Documentation","title":"SFTPClient.SFTP","text":"function SFTP(url::AbstractString, username::AbstractString;disableverifypeer=false, disableverifyhost=false)\n\nCreates a new SFTP client using certificate authentication, and keys in the files specified\n\nsftp = SFTP(\"sftp://mysitewhereIhaveACertificate.com\", \"myuser\", \"test.pub\", \"test.pem\")\n\n\n\n\n\n","category":"method"},{"location":"reference/#SFTPClient.SFTP-Tuple{AbstractString, AbstractString, AbstractString}","page":"SFTPClient API Documentation","title":"SFTPClient.SFTP","text":"function SFTP(url::AbstractString, username::AbstractString, password::AbstractString;createknownhostsentry=true, disableverifypeer=false, disableverify_host=false)\n\nCreates a new SFTP Client: url: The url to connect to, e.g., sftp://mysite.com username: The username to use password: The users password createknownhosts_entry: Automatically create an entry in known hosts\n\nExample: sftp = SFTP(\"sftp://test.rebex.net\", \"demo\", \"password\")\n\n\n\n\n\n","category":"method"},{"location":"reference/#SFTPClient.SFTP-Tuple{AbstractString, AbstractString}","page":"SFTPClient API Documentation","title":"SFTPClient.SFTP","text":"function SFTP(url::AbstractString, username::AbstractString;disableverifypeer=false, disableverifyhost=false)\n\nCreates a new SFTP client using certificate authentication. \n\nsftp = SFTP(\"sftp://mysitewhereIhaveACertificate.com\", \"myuser\")\n\nNote! You must provide the username for this to work. \n\nBefore using this method, you must set up your certificates in ~/.ssh/idrsa and ~/.ssh/idrsa.pub\n\nOf course, the host need to be in the known_hosts file as well. \n\nTest using your local client first: ssh myuser@mysitewhereIhaveACertificate.com\n\nSee other method if you want to use files not in ~/ssh/\n\n\n\n\n\n","category":"method"},{"location":"#Julia-SFTP-Client","page":"Julia SFTP Client","title":"Julia SFTP Client","text":"","category":"section"},{"location":"","page":"Julia SFTP Client","title":"Julia SFTP Client","text":"An SFTP Client for Julia.","category":"page"},{"location":"","page":"Julia SFTP Client","title":"Julia SFTP Client","text":"A julia package for communicating with SFTP Servers, supporting username and password, or certificate authentication. ","category":"page"},{"location":"#SFTPClient-Features","page":"Julia SFTP Client","title":"SFTPClient Features","text":"","category":"section"},{"location":"","page":"Julia SFTP Client","title":"Julia SFTP Client","text":"- readdir\n- download\n- upload \n- cd\n- rm \n- rmdir\n- mkdir\n- mv\n- sftpstat (like stat, but more limited)","category":"page"},{"location":"#SFTPClient-Installation","page":"Julia SFTP Client","title":"SFTPClient Installation","text":"","category":"section"},{"location":"","page":"Julia SFTP Client","title":"Julia SFTP Client","text":"Install by running:","category":"page"},{"location":"","page":"Julia SFTP Client","title":"Julia SFTP Client","text":"import Pkg;Pkg.add(\"SFTPClient\")","category":"page"},{"location":"#SFTPClient-Examples","page":"Julia SFTP Client","title":"SFTPClient Examples","text":"","category":"section"},{"location":"","page":"Julia SFTP Client","title":"Julia SFTP Client","text":"\n using SFTPClient\n sftp = SFTP(\"sftp://test.rebex.net/pub/example/\", \"demo\", \"password\")\n files=readdir(sftp)\n # On Windows, replace this with an appropriate path\n downloadDir=\"/tmp/\"\n SFTPClient.download.(sftp, files, downloadDir=downloadDir)\n","category":"page"},{"location":"","page":"Julia SFTP Client","title":"Julia SFTP Client","text":" #You can also use it like this\n df=DataFrame(CSV.File(SFTPClient.download(sftp, \"/mydir/test.csv\")))\n\n # For certificate authentication, you can do this (since 0.3.8)\n sftp = SFTP(\"sftp://mysitewhereIhaveACertificate.com\", \"myuser\", \"cert.pub\", \"cert.pem\")\n \n # The cert.pem is your certificate (private key), and the cert.pub can be obtained from the private # key as following: ssh-keygen -y -f ./cert.pem. Save the output into \"cert.pub\". \n","category":"page"}] } diff --git a/dev/troubleshooting/index.html b/dev/troubleshooting/index.html index e1c4103..489c2d5 100644 --- a/dev/troubleshooting/index.html +++ b/dev/troubleshooting/index.html @@ -1,2 +1,2 @@ -Troubleshooting · Julia SFTPClient Documentation

Troubleshooting

If you get: RequestError: Failure establishing ssh session: -5, Unable to exchange encryption keys while requesting... Try and upgrade to Julia 1.9.4. It seems to be a bug in an underlying library.

If it does not work, check your known_hosts file in your .ssh directory. ED25519 keys do not seem to work.

Use the ssh-keyscan tool: From command line, execute: ssh-keyscan [hostname]. Add the ecdsa-sha2-nistp256 line to your knownhosts file. This file is located in your .ssh-directory. This is directory is located in C:\Users\{youruser}\.ssh on Windows and ~/.ssh on Linux.

___Note: Setting up certificate authentication___

To set up certificate authentication, create the certificates in the ~/.ssh/idrsa and ~/.ssh/idrsa.pub files. On Windows these are located in C:\Users\{your user}\.ssh.

Then use the function sftp = SFTP("sftp://mysitewhereIhaveACertificate.com", "myuser") to create a SFTP type.

Example files

___in "known_hosts"___ mysitewhereIhaveACertificate.com ssh-rsa sdsadxcvacvljsdflsajflasjdfasldjfsdlfjsldfj

___in "id_rsa"___

––-BEGIN RSA PRIVATE KEY––- ..... cu1sTszTVkP5/rL3CbI+9rgsuCwM67k3DiH4JGOzQpMThPvolCg=

––-END RSA PRIVATE KEY––-

___in id_rsa.pub___ ssh-rsa AAAAB3...SpjX/4t Comment here

After setting up the files, test using your local sftp client:

ssh myuser@mysitewhereIhaveACertificate.com

___Known bugs___

Currently some operations, e.g. mv fails if the remote path has a space or special character in it. It works for files having space in them, but not for directories having space in them.

+Troubleshooting · Julia SFTPClient Documentation

Troubleshooting

If you get: RequestError: Failure establishing ssh session: -5, Unable to exchange encryption keys while requesting... Try and upgrade to Julia 1.9.4. It seems to be a bug in an underlying library.

If it does not work, check your known_hosts file in your .ssh directory. ED25519 keys do not seem to work.

Use the ssh-keyscan tool: From command line, execute: ssh-keyscan [hostname]. Add the ecdsa-sha2-nistp256 line to your knownhosts file. This file is located in your .ssh-directory. This is directory is located in C:\Users\{youruser}\.ssh on Windows and ~/.ssh on Linux.

___Note: Setting up certificate authentication___

To set up certificate authentication, create the certificates in the ~/.ssh/idrsa and ~/.ssh/idrsa.pub files. On Windows these are located in C:\Users\{your user}\.ssh.

Then use the function sftp = SFTP("sftp://mysitewhereIhaveACertificate.com", "myuser") to create a SFTP type.

Example files

___in "known_hosts"___ mysitewhereIhaveACertificate.com ssh-rsa sdsadxcvacvljsdflsajflasjdfasldjfsdlfjsldfj

___in "id_rsa"___

––-BEGIN RSA PRIVATE KEY––- ..... cu1sTszTVkP5/rL3CbI+9rgsuCwM67k3DiH4JGOzQpMThPvolCg=

––-END RSA PRIVATE KEY––-

___in id_rsa.pub___ ssh-rsa AAAAB3...SpjX/4t Comment here

After setting up the files, test using your local sftp client:

ssh myuser@mysitewhereIhaveACertificate.com