ssh_sftpd(3erl)

πŸ’… ssh_sftpd β€” Erlang Module Definition πŸŽ€

okay so bestie, welcome to ssh_sftpd β€” this is the Erlang module definition for the SFTP subsystem situation, and honestly it's giving "small module, big responsibilities." let's get into it ✨


🌸 NAME 🌸

ssh_sftpd β€” literally specifies the channel process to handle an SFTP subsystem. that's the whole vibe. 🫢


πŸ¦‹ DESCRIPTION πŸ¦‹

so like, this module specifies a channel process to handle an SFTP subsystem. no cap, that's what it does. it's the plug that makes SFTP happen over your SSH setup. πŸ’–


✨ EXPORTS ✨

πŸ’« subsystem_spec(Options) -> Spec

okay so first things first, the types, because we stay informed in this group chat:

Options =
    [{cwd, string()} |
     {file_handler, CbMod | {CbMod, FileState}} |
     {max_files, integer()} |
     {max_handles, integer()} |
     {max_path, integer()} |
     {root, string()} |
     {sftpd_vsn, integer()}]
Spec = {Name, {CbMod, Options}}
Name = string()
CbMod = atom()
FileState = term()

this bad boy is meant to be used together with ssh:daemon/[1,2,3]. yes, the whole [1,2,3] arity moment β€” iconic, honestly. πŸ‘‘

the Name is "sftp" and CbMod is the name of the Erlang module implementing the subsystem using the ssh_server_channel behaviour β€” and yes, that replaces ssh_daemon_channel, so don't come at me with the old one, iykyk. πŸ’…

now the options, because there are a bunch and they all matter:

  • cwd β€” sets the initial current working directory for the server. like, where you start. the starting point. the main character's origin story. πŸŽ€
  • file_handler β€” determines which module to call for accessing the file server. the default value is ssh_sftpd_file, which uses the file and filelib APIs to access the standard OTP file server. this option can be used to plug in other file servers. so like, bring your own file server if you want, bestie. πŸ¦‹
  • max_files β€” the default value is 0, which means there is no upper limit. if supplied, the number of filenames returned to the SFTP client per READDIR request is limited to at most the given value. so 0 is giving "no rules, just vibes," and anything else is giving "actually, let's put a cap on it." 🌸
  • root β€” sets the SFTP root directory. then the user cannot see any files above this root. if, for example, the root directory is set to /tmp, then the user sees this directory as /. if the user then writes cd /etc, the user moves to /tmp/etc. yes, it's a whole illusion situation. the root is the root, periodt. 🌈
  • sftpd_vsn β€” sets the SFTP version to use. defaults to 5. version 6 is under development and limited. so like, v6 is still in its beta era β€” proceed accordingly. πŸ’€
⚠️ heads up bestie: version 6 is under development and limited β€” that's straight from the source, don't @ me. πŸ”₯

that's the whole page, no missing details, no skipped options, we ate and left no crumbs πŸ’…βœ¨

β€” with love from Ericsson AB, the ssh 4.15.3.1 era, dated ssh_sftpd(3erl) πŸŽ€πŸ«ΆπŸ’–

πŸ“¦ where this page comes from