--- runopts.h
+++ runopts.h
@@ -68,6 +68,10 @@
 
 typedef struct svr_runopts {
 
+#ifdef DROPBEAR_SFTPSERVER
+	char * sftppath;
+#endif
+
 	char * bannerfile;
 
 	int forkbg;
--- svr-chansession.c
+++ svr-chansession.c
@@ -687,7 +687,7 @@
 			if ((cmdlen == 4) && strncmp(chansess->cmd, "sftp", 4) == 0) {
 				char *expand_path = expand_homedir_path(SFTPSERVER_PATH);
 				m_free(chansess->cmd);
-				chansess->cmd = m_strdup(expand_path);
+				chansess->cmd = m_strdup(svr_opts.sftppath);
 				m_free(expand_path);
 			} else 
 #endif
--- svr-runopts.c
+++ svr-runopts.c
@@ -63,6 +63,10 @@
 #if DROPBEAR_DELAY_HOSTKEY
 					"-R		Create hostkeys as required\n" 
 #endif
+#ifdef DROPBEAR_SFTPSERVER
+					"-S sftpserver	Set path to sftp server\n"
+					"		(default: %s)\n"
+#endif
 					"-F		Don't fork into background\n"
 					"-e		Pass on server process environment to child process\n"
 #ifdef DISABLE_SYSLOG
@@ -125,6 +129,9 @@
 #if DROPBEAR_ED25519
 					ED25519_PRIV_FILENAME,
 #endif
+#ifdef DROPBEAR_SFTPSERVER
+					SFTPSERVER_PATH,
+#endif
 					MAX_AUTH_TRIES,
 					DROPBEAR_MAX_PORTS, DROPBEAR_DEFPORT, DROPBEAR_PIDFILE,
 					DEFAULT_RECV_WINDOW, DEFAULT_KEEPALIVE, DEFAULT_IDLE_TIMEOUT);
@@ -147,6 +154,9 @@
 
 
 	/* see printhelp() for options */
+#ifdef DROPBEAR_SFTPSERVER
+	svr_opts.sftppath = NULL;
+#endif
 	svr_opts.bannerfile = NULL;
 	svr_opts.banner = NULL;
 	svr_opts.forced_command = NULL;
@@ -219,6 +229,11 @@
 				case 'R':
 					svr_opts.delay_hostkey = 1;
 					break;
+#ifdef DROPBEAR_SFTPSERVER
+				case 'S':
+					next = &svr_opts.sftppath;
+					break;
+#endif
 				case 'F':
 					svr_opts.forkbg = 0;
 					break;
@@ -365,6 +380,12 @@
 		svr_opts.portcount = 1;
 	}
 
+#ifdef DROPBEAR_SFTPSERVER
+	if (svr_opts.sftppath == NULL) {
+		svr_opts.sftppath = SFTPSERVER_PATH;
+	}
+#endif
+
 	if (svr_opts.bannerfile) {
 		struct stat buf;
 		if (stat(svr_opts.bannerfile, &buf) != 0) {
