{"id":24755242,"url":"https://github.com/katzer/mruby-sftp","last_synced_at":"2026-03-06T10:04:47.633Z","repository":{"id":138108993,"uuid":"124243008","full_name":"katzer/mruby-sftp","owner":"katzer","description":"SFTP client for mruby","archived":false,"fork":false,"pushed_at":"2024-08-24T16:38:19.000Z","size":136,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-01T14:41:28.546Z","etag":null,"topics":["mruby-gem","sftp","sftp-client","ssh"],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/katzer.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-03-07T13:52:20.000Z","updated_at":"2024-08-24T16:38:23.000Z","dependencies_parsed_at":"2025-01-28T12:37:56.380Z","dependency_job_id":"9de29ec3-c456-45ac-a774-6730f4fb3f56","html_url":"https://github.com/katzer/mruby-sftp","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/katzer/mruby-sftp","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/katzer%2Fmruby-sftp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/katzer%2Fmruby-sftp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/katzer%2Fmruby-sftp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/katzer%2Fmruby-sftp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/katzer","download_url":"https://codeload.github.com/katzer/mruby-sftp/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/katzer%2Fmruby-sftp/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30171656,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-06T07:56:45.623Z","status":"ssl_error","status_checked_at":"2026-03-06T07:55:55.621Z","response_time":250,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["mruby-gem","sftp","sftp-client","ssh"],"created_at":"2025-01-28T12:37:52.023Z","updated_at":"2026-03-06T10:04:43.383Z","avatar_url":"https://github.com/katzer.png","language":"Ruby","readme":"# SFTP client for mruby \u003cbr\u003e [![Build Status](https://travis-ci.com/katzer/mruby-sftp.svg?branch=master)](https://travis-ci.com/katzer/mruby-sftp) [![Build status](https://ci.appveyor.com/api/projects/status/pggp2jp2287ogqjm/branch/master?svg=true)](https://ci.appveyor.com/project/katzer/mruby-sftp/branch/master) [![codebeat badge](https://codebeat.co/badges/6314e973-d325-4366-a227-48e2023db7c2)](https://codebeat.co/projects/github-com-katzer-mruby-sftp-master)\n\nInspired by [Net::SFTP][net_sftp], empowers [mruby][mruby], a work in progress!\n\nThe SFTP client is based on [mruby-ssh][mruby_ssh] and [libssh2][libssh2]. The API design follows Net::SFTP as much as possible.\n\nThe resulting binary will be statically linked agains _libssh2_ and _mbedtls_. There are no external runtime dependencies and the code should run fine for Linux, Unix and Windows platform.\n\nThe snippet demontrates how to read a remote file line by line:\n\n```ruby\nSFTP.start('test.rebex.net', 'demo', password: 'password') do |sftp|\n  sftp.file.open('readme.txt', 'r') do |file|\n    file.each_line(chomp: true) { |line| puts line }\n  end\nend\n```\n\n## Installation\n\nAdd the line below to your `build_config.rb`:\n\n```ruby\nMRuby::Build.new do |conf|\n  # ... (snip) ...\n  conf.gem 'mruby-sftp'\nend\n```\n\nOr add this line to your aplication's `mrbgem.rake`:\n\n```ruby\nMRuby::Gem::Specification.new('your-mrbgem') do |spec|\n  # ... (snip) ...\n  spec.add_dependency 'mruby-sftp'\nend\n```\n\n## Usage\n\nTo initiate a SFTP session it is recommended to use either `SFTP.start`\n\n```ruby\nSFTP.start('test.rebex.net', 'demo', password: 'password') do |sftp|\n  sftp # =\u003e SFTP::Session\nend\n```\n\nor `SSH::Session#sftp`\n\n```ruby\nSSH.start('test.rebex.net', 'demo', key: '~/.ssh/id_rsa') do |session|\n  session.sftp # =\u003e SFTP::Session\nend\n```\n\n_SFTP.start works the same way like _SSH.start. See the doc for [mruby-ssh][mruby_ssh] for how to connect and login to a SSH server.\n\n### SFTP::Session\n\nThe Session class encapsulates a single SFTP channel on a SSH connection. Instances of this class are what most applications will interact with most, as it provides access to both low-level (mkdir, rename, remove, symlink, etc.) and high-level (upload, download, etc.) SFTP operations.\n\n```ruby\nSFTP.start('test.rebex.net', 'demo', password: 'password') do |sftp|\n  sftp.download('remote/file', 'local/file') if sftp.exist? 'remote/file'\n  sftp.upload('local/file', 'remote/file')\nend\n```\n\nSee [session.rb](mrblib/sftp/session.rb) and [session.c](src/session.c) for a complete list of available methods.\n\n### SFTP::Stat\n\nA class representing the attributes of a file or directory on the server. It may be used to specify new attributes, or to query existing attributes.\n\n```ruby\nSFTP.start('test.rebex.net', 'demo', password: 'password') do |sftp|\n  sftp.stat('remote/file').size\n  sftp.lstat('remote/file').file?\n  sftp.fstat(file).uid\n  sftp.setstat('remote/file', gid: 104)\nend\n```\n\nSee [stat.rb](mrblib/sftp/stat.rb) and [stat.c](src/stat.c) for a complete list of available methods.\n\n### SFTP::Dir\n\nA convenience class for working with remote directories. It provides methods for searching and enumerating directory entries, similarly to the standard ::Dir class.\n\n```ruby\nSFTP.start('test.rebex.net', 'demo', password: 'password') do |sftp|\n  sftp.dir.foreach('/') do |entry|\n    entry.name       # =\u003e 'readme.txt'\n    entry.longname   # =\u003e '-rw------- 1 demo users        403 Apr 08  2014 readme.txt'\n    entry.stats.size # =\u003e 403\n  end\nend\n```\n\nSee [dir.rb](mrblib/sftp/dir.rb) for a complete list of available methods.\n\n### SFTP::File\n\nA wrapper around an SFTP file handle, that exposes an IO-like interface for interacting with the remote file.\n\n```ruby\nSFTP.start('test.rebex.net', 'demo', password: 'password') do |sftp|\n  sftp.file.open('readme.txt', 'r') do |file|\n    file.readline  # =\u003e Read first line\n    file.gets(5)   # =\u003e Read next 5 characters\n    file.gets(nil) # =\u003e Read until end of file\n    file.eof?      # =\u003e true\n  end\nend\n```\n\nSee [file_factory.rb](mrblib/sftp/file_factory.rb), [file.rb](mrblib/sftp/file.rb), [file.c](src/file.c), [handle.rb](mrblib/sftp/handle.rb) and [handle.c](src/handle.c) for a complete list of available methods.\n\n### Build Flags\n\nThe underlying [mruby-ssh][mruby_ssh] mgem offers a set of build flags that are useful for SFTP operations.\n\n#### Compression\n\nTo speed up the download/upload of files its possible to enable compression. The feature is optional and disabled by default.\n\nTo make us of it add the line below to your `build_config.rb`:\n\n```ruby\nMRuby::Build.new do |conf|\n  # ... (snip) ...\n  conf.cc.defines += %w[LIBSSH2_HAVE_ZLIB HAVE_UNISTD_H]\nend\n```\n\nOr add this line to your aplication's `mrbgem.rake`:\n\n```ruby\nMRuby::Gem::Specification.new('your-mrbgem') do |spec|\n  # ... (snip) ...\n  spec.mruby.cc.defines += %w[LIBSSH2_HAVE_ZLIB HAVE_UNISTD_H]\nend\n```\n\nNow initiate a new SFTP session with `compress:true`:\n\n```ruby\nSFTP.start('test.rebex.net', 'demo', password: 'password', compress: true)\n``` \n\n#### Optimize memory footprint\n\nIts possible to reduce the memory footprint by a few kB if the tool only depend on SFTP operations without the need of advanced SSH functionality.\n\nTo make us of it add the line below to your `build_config.rb`:\n\n```ruby\nMRuby::Build.new do |conf|\n  # ... (snip) ...\n  conf.cc.defines \u003c\u003c 'MRB_SSH_TINY'\nend\n```\n\nOr add this line to your aplication's `mrbgem.rake`:\n\n```ruby\nMRuby::Gem::Specification.new('your-mrbgem') do |spec|\n  # ... (snip) ...\n  spec.mruby.cc.defines \u003c\u003c 'MRB_SSH_TINY'\nend\n```\n\n\n## Development\n\nClone the repo:\n    \n    $ git clone https://github.com/katzer/mruby-sftp.git \u0026\u0026 cd mruby-sftp/\n\nCompile the source:\n\n    $ rake compile\n\nRun the tests:\n\n    $ rake test\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/katzer/mruby-sftp.\n\n1. Fork it\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create new Pull Request\n\n## Authors\n\n- Sebastián Katzer, Fa. appPlant GmbH\n\n## License\n\nThe mgem is available as open source under the terms of the [MIT License][license].\n\nMade with :yum: in Leipzig\n\n© 2017 [appPlant GmbH][appplant]\n\n[mruby]: https://github.com/mruby/mruby\n[net_sftp]: https://github.com/net-ssh/net-sftp\n[mruby_ssh]: https://github.com/katzer/mruby-ssh\n[libssh2]: https://www.libssh2.org\n[license]: http://opensource.org/licenses/MIT\n[appplant]: www.appplant.de\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkatzer%2Fmruby-sftp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkatzer%2Fmruby-sftp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkatzer%2Fmruby-sftp/lists"}