README.md

Rebex SFTP Server

  1. Quickstart
  2. Server configuration
  3. Running the Service in Command Line
  4. User Management
  5. Service Installation
  6. Tools
  7. Logging
  8. SSH Shell configuration (experimental)

Quickstart

cmd.exe

sftpserver adduser guybrush C:\some_existing_folder --password elaine 
sftpserver run

bash

./sftpserver.exe adduser guybrush /home/scabb --password elaine 
./sftpserver.exe run

Server configuration

See README_CONFIG

Running the service in command line

sftpserver run Runs the service in command line.

# Start the SFTP server
sftpserver run

User Management

sftpserver adduser Permanently adds user to the SFTP user directory.

# add user 'guybrush' with home directory at '/home/guybrush' and password 'elaine'
# guybrush will use password authentication
sftpserver adduser guybrush /home/guybrush --password elaine
# add user 'lechuck' with public key stored in '~/home/lechuck/.ssh/rsa.pub' 
# lechuck will use public key authentication
sftpserver adduser lechuck /home/lechuck --keys ~/home/lechuck/.ssh/rsa.pub

sftpserver removeuser Permanently removes user from the SFTP user directory.

sftpserver removeuser lechuck

sftp updateuser Modifies existing user in the SFTP user directory.

# Change password to 'kate' for user guybrush
sftpserver updateuser guybrush --password kate
# Change root directory to /home/phatt with read-write access
sftpserver updateuser guybrush -r /home/phatt --readwrite
# Replace existing public keys for user guybrush
sftpserver updateuser guybrush --setkeys /home/guybrush/.ssh/rsa.pub

Service Installation

sftpserver install Installs SFTP server as Windows service

sftpserver install
net start sftpserver

sftpserver uninstall Uninstalls SFTP server service (actually uninstalls ANY service that goes by the specified name).

net stop sftpserver
sftpserver uninstall

Tools

sftpserver keygen Generates SSH private keys

# Generate 4096-bit RSA key and save it to key.ppk file.
sftpserver keygen -f key.ppk
# Generate 512-bit DSA key and save it to key.ppk file.
sftpserver keygen -f key.ppk -t dsa -b 512

Logging

Rebex Sftp Server uses NLog to perform all logging, including access logs. See NLog Configuration Documentation for further details and modify NLog.config file accordingly.

To enable access log, add target for logger Rebex.SftpServer.ConsoleApp.AccessLogger, e.g.:

<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" 
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <targets>
    <target name="co" xsi:type="ColoredConsole" layout="${time} ${message}" />
    <target name="accessLog" xsi:type="File" layout="${message}" fileName="C:\logs\accesslog.csv" />
  </targets>

  <rules>
    <logger name="Rebex.SftpServer.ConsoleApp.AccessLogger" writeTo="accessLog" final="true" />
    <logger name="*" minlevel="Debug" writeTo="co" />    
  </rules>
</nlog>

SSH Shell configuration

See README_ALIASES