SFTP
How to use goshs as SFTP server
You can use goshs to also provide the files using SFTP by using -sftp. The default SFTP port is 2022 and can be changed using -sp.
Authentication is required using SFTP. You can use either username and password authentication with the flag -b user:pass or you can use an authorized keys file with -skf <file-path>. The options can be used exclusively or together.
As the embedded ssh server will generate a host key everytime you run it you will get error messages when connecting two times to the SFTP server when rerunning the binary. You can generate a permanent host key by running ssh-keygen -f ./goshs_rsa_key -N "" -t rsa and then providing the host key file to goshs using the command flag -shk goshs_rsa_key.
The SFTP server also supports read-only (-ro) and upload-only (-uo) modes, and respects the web root set with -d.
# Password authentication
goshs -sftp -b user:password
# Public key authentication
goshs -sftp -skf ~/.ssh/authorized_keys
# Both methods, read-only, permanent host key
goshs -sftp -b user:password -skf ~/.ssh/authorized_keys -ro -shk ./goshs_rsa_keyConnect with any standard SFTP client:
sftp -P 2022 user@<your-ip>