{"id":20850439,"url":"https://github.com/noteed/sftp-streams","last_synced_at":"2025-05-12T04:31:27.232Z","repository":{"id":18903651,"uuid":"22122022","full_name":"noteed/sftp-streams","owner":"noteed","description":"SFTP protocol","archived":false,"fork":false,"pushed_at":"2015-11-06T14:03:03.000Z","size":200,"stargazers_count":7,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2023-04-13T10:31:56.598Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Haskell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/noteed.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}},"created_at":"2014-07-22T21:45:42.000Z","updated_at":"2019-08-01T07:49:59.000Z","dependencies_parsed_at":"2022-08-05T01:15:27.938Z","dependency_job_id":null,"html_url":"https://github.com/noteed/sftp-streams","commit_stats":null,"previous_names":[],"tags_count":0,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/noteed%2Fsftp-streams","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/noteed%2Fsftp-streams/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/noteed%2Fsftp-streams/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/noteed%2Fsftp-streams/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/noteed","download_url":"https://codeload.github.com/noteed/sftp-streams/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225120017,"owners_count":17423818,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":[],"created_at":"2024-11-18T03:09:31.061Z","updated_at":"2024-11-18T03:09:31.674Z","avatar_url":"https://github.com/noteed.png","language":"Haskell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# sftp-streams\n\nAttempt to implement the SSH File Transfer Protocol.\n\n## Status\n\nThere are two small binaries: `sftp-mitm` and `sftp-mem`.\n\n`sftp-mitm` can sit between `sshd` and the SFTP SSH subsystem (e.g. on Ubuntu\nthis is `/usr/lib/openssh/sftp-server`). It parses the packets exchanged by a\nregular client and the real SFTP program on the server, and display them.\n\n`sftp-mem` implements a few commands. Those commands are exercised in\n`test-sftp-mem.sh` and can be compared to `test-sftp-mitm.sh`. They can be seen\nin [test-batch.txt](test-batch.txt).\n\n`test-sftp-sshs.sh` uses SSHFS to talk to `sftp-mem`.\n\n## Docker image\n\nPaths are hard-coded in the executable. There is a Dockerfile to create an\nimage that matches the expectations. Before building the image, you need to\nprovide a public SSH key `insecure_id_rsa.pub` and the `sftp-mitm` binary (put\nthem in the `images/sftp-mitm` directory). Same for `sftp-mem`.\n\n## Notes\n\nI have started to implement this package by looking at\nhttp://tools.ietf.org/html/draft-ietf-secsh-filexfer-13 (which describes\nprotocol version 6) then I have switched to\nhttp://tools.ietf.org/html/draft-ietf-secsh-filexfer-02 when I saw that my\nclient was using protocol version 3.\n\nThe version of `sftp` (i.e. the client) I used defaults to protocol version 3.\nI have not tried protocol versions 1 and 2 (accessible with the `-1` and `-2`\nflags). \n\nThe client can re-use packet IDs very quickly (e.g. after 3 or 4 requests).\n\n`SSH_FXP_READ` packets request 32768 bytes at a time. I think I can use the\n`-B` flag to influence that size.\n\nIf the server response includes less than the requested size, the client will\nissue a second request to try to get the \"missing\" bytes, but not again 32768\nbytes. It does so even if the preceding `SSH_FXP_STAT` request lets it know the\nsize of the file and thus that the file was complete.\n\nIt is necessary to create a directory that you plan to transfer with `put -r`:\n\n    \u003e mkdir some-directory\n    \u003e put -r some-directory\n\notherwise the server fails. I think the reason is that the client first issues\n`SSH_FXP_REALPATH` to get the correct path of the directory before transfering\nit. That requests fail because the path doesn't exist yet.\n\nActually, by preceding the `put -r` by `mkdir`, everything (from the user point\nof view) works. In reality, the `put -r` also tries to do a `SSH_FXP_MKDIR`\nwhich fails because the directory already exists.\n\nFor debugging, I could have used the `-D` flag instead of passing through sshd.\n\nInstead of configuring sshd's subsystem to use the `sftp-mitm` program, the\n`-s` option could have been used.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnoteed%2Fsftp-streams","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnoteed%2Fsftp-streams","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnoteed%2Fsftp-streams/lists"}