How to run ftp-server on port 21 on macOs

Viewed 277

I have to run ftpserver with node.js and electron, using simple-ftpd on macOs. It must run on port 21, because i can't update device's hardwares parameters. Btw all ports < 1024 are locked.

I tried to use pfctl to forward 21 -> 1337, my device can find the ftpserver but can't log or write into it.

echo “rdr pass on en0 inet proto tcp from any to any port 21 -> 127.0.0.1 port 1337” | sudo pfctl -ef -

I dont want to ask for root password after each launch.

i'm using node 8, electron, simple-ftdp

Do you have any suggestions guys ?

1 Answers

You have to be careful with this one, but you can allow your user to run sudo simple-ftpd with no password by adding /etc/sudoers.d/myappconfig with:

myuser ALL=(ALL) NOPASSWD: /usr/bin/path/to/simpleftp-d

If it doesn't work or you don't have the folder /etc/sudoers.d/, you can just append that line to /etc/sudoers.

Related