Bugfix and small feature release.

First release in some time. Fixing lots of bugs and adds a few new
features. Below are the highlights.

* [GH-301] support rename extension for server
* [GH-332] Added a ClientOption to determine whether to use Fstat or Stat
* [GH-315] make SFTP extensions configurable

* [GH-291] Wrong S_IFMT mask when converting filemode bits to os.FileMode
* [GH-295] sftp resume produces corrupted files
* [GH-298] Extensions are not announced by the server
* [GH-329] fix S_IFMT value on windows, plan9 and js/wasm
* [GH-325] Request.Attributes() panics when called with the Attr slice empty
* [GH-309] fix: received packet too long

Thanks to all the contributors. Your time and patience is appreciated.

Merge pull request #332 from peachfinance/Fstat-stat-options

Added a ClientOption to determine whetehr to use Fstat or Stat when File.WriteTo is being called to support strange behaviour on some servers
tree: 00093c8dd1b99ed7a244b84698ff06a04f43f45c
  1. .gitignore
  2. .travis.yml
  5. Makefile
  6. README.md
  7. attrs.go
  8. attrs_stubs.go
  9. attrs_test.go
  10. attrs_unix.go
  11. client.go
  12. client_integration_darwin_test.go
  13. client_integration_linux_test.go
  14. client_integration_test.go
  15. client_test.go
  16. conn.go
  17. debug.go
  18. example_test.go
  19. examples/
  20. go.mod
  21. go.sum
  22. match.go
  23. packet-manager.go
  24. packet-manager_test.go
  25. packet-typing.go
  26. packet.go
  27. packet_test.go
  28. release.go
  29. request-attrs.go
  30. request-attrs_test.go
  31. request-errors.go
  32. request-example.go
  33. request-interfaces.go
  34. request-readme.md
  35. request-server.go
  36. request-server_test.go
  37. request-unix.go
  38. request.go
  39. request_test.go
  40. request_windows.go
  41. server.go
  42. server_integration_test.go
  43. server_standalone/
  44. server_statvfs_darwin.go
  45. server_statvfs_impl.go
  46. server_statvfs_linux.go
  47. server_statvfs_stubs.go
  48. server_stubs.go
  49. server_test.go
  50. server_unix.go
  51. sftp.go
  52. sftp_test.go
  53. syscall_fixed.go
  54. syscall_good.go


The sftp package provides support for file system operations on remote ssh servers using the SFTP subsystem. It also implements an SFTP server for serving files from the filesystem.

UNIX Build Status GoDoc

usage and examples

See godoc.org/github.com/pkg/sftp for examples and usage.

The basic operation of the package mirrors the facilities of the os package.

The Walker interface for directory traversal is heavily inspired by Keith Rarick's fs package.


  • There is way too much duplication in the Client methods. If there was an unmarshal(interface{}) method this would reduce a heap of the duplication.


We welcome pull requests, bug fixes and issue reports.

Before proposing a large change, first please discuss your change by raising an issue.

For API/code bugs, please include a small, self contained code example to reproduce the issue. For pull requests, remember test coverage.

We try to handle issues and pull requests with a 0 open philosophy. That means we will try to address the submission as soon as possible and will work toward a resolution. If progress can no longer be made (eg. unreproducible bug) or stops (eg. unresponsive submitter), we will close the bug.