Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I use SFTP without SSH?

Tags:

server

sftp

I want a fast and flexible file server but I don't need encryption or authentication. How can I use SFTP for this on Linux systems?

like image 466
Kyler Laird Avatar asked Dec 01 '25 05:12

Kyler Laird


1 Answers

SFTP happens to be used by SSH servers but it's a well-developed protocol that works well on its own. The sftp-server developed by OpenSSH has no dependency on an SSH server; sftp-server uses standard input/output. (Other SFTP servers are similar.)

It is trivial to share a filesystem via SFTP, similar to what you might do with NFS but without the need for root access. I'll use socat as the daemon for this ad-hoc example, but xinetd would make a more permanent solution. The location of sftp-server is from my Ubuntu installation of the openssh-sftp-server package.

On the server:

$ mkdir shared_to_the_world
$ cd shared_to_the_world
$ socat tcp-listen:1234,reuseaddr,fork exec:/usr/lib/openssh/sftp-server

On the client:

$ mkdir /tmp/sftp_test
$ sshfs -o reconnect,ssh_command="nc my_sftp_server_address 1234 --" : /tmp/sftp_test
$ cd /tmp/sftp_test

Now your client (and anyone else's!) can seamlessly work with the files in the shared directory on the server. Both read and write are enabled, so be careful.

Consider using socat listen's "bind" and "range" options to limit the access to your server.

like image 90
Kyler Laird Avatar answered Dec 04 '25 23:12

Kyler Laird