diff --git a/cli-runopts.c b/cli-runopts.c
index ea178c7deea94b86c9074bfa0bdad262fa40f9e6..0522221e3cc9dddfc395b1ef863772440e5becce 100644
--- a/cli-runopts.c
+++ b/cli-runopts.c
@@ -148,6 +148,9 @@ void cli_getopts(int argc, char ** argv) {
 #ifdef ENABLE_CLI_PUBKEY_AUTH
 	cli_opts.privkeys = list_new();
 #endif
+#ifdef ENABLE_CLI_ANYTCPFWD
+	cli_opts.exit_on_fwd_failure = 0;
+#endif
 #ifdef ENABLE_CLI_LOCALTCPFWD
 	cli_opts.localfwds = list_new();
 	opts.listen_fwd_all = 0;
@@ -854,9 +857,20 @@ static void add_extendedopt(const char* origstr) {
 	const char *optstr = origstr;
 
 	if (strcmp(origstr, "help") == 0) {
-		dropbear_log(LOG_INFO, "No options available\n");
+		dropbear_log(LOG_INFO, "Available options:\n"
+#ifdef ENABLE_CLI_ANYTCPFWD
+			"\tExitOnForwardFailure\n"
+#endif
+		);
 		exit(EXIT_SUCCESS);
 	}
 
+#ifdef ENABLE_CLI_ANYTCPFWD
+	if (match_extendedopt(&optstr, "ExitOnForwardFailure") == DROPBEAR_SUCCESS) {
+		cli_opts.exit_on_fwd_failure = parse_flag_value(optstr);
+		return;
+	}
+#endif
+
 	dropbear_exit("Bad configuration option '%s'", origstr);
 }
diff --git a/cli-tcpfwd.c b/cli-tcpfwd.c
index ec65f410f282032e8a889ac49a5eed94fd57b7d6..4d46b94e58c3da304c57fabd5814fdb769fab248 100644
--- a/cli-tcpfwd.c
+++ b/cli-tcpfwd.c
@@ -60,6 +60,22 @@ static const struct ChanType cli_chan_tcplocal = {
 };
 #endif
 
+#ifdef ENABLE_CLI_ANYTCPFWD
+static void fwd_failed(const char* format, ...) ATTRIB_PRINTF(1,2);
+void fwd_failed(const char* format, ...)
+{
+	va_list param;
+	va_start(param, format);
+
+	if (cli_opts.exit_on_fwd_failure)
+		_dropbear_exit(EXIT_FAILURE, format, param);
+	else
+		_dropbear_log(LOG_WARNING, format, param);
+
+	va_end(param);
+}
+#endif
+
 #ifdef ENABLE_CLI_LOCALTCPFWD
 void setup_localtcp() {
 	m_list_elem *iter;
@@ -75,7 +91,7 @@ void setup_localtcp() {
 				fwd->connectaddr,
 				fwd->connectport);
 		if (ret == DROPBEAR_FAILURE) {
-			dropbear_log(LOG_WARNING, "Failed local port forward %s:%d:%s:%d",
+			fwd_failed("Failed local port forward %s:%d:%s:%d",
 					fwd->listenaddr,
 					fwd->listenport,
 					fwd->connectaddr,
@@ -181,7 +197,10 @@ void cli_recv_msg_request_failure() {
 		struct TCPFwdEntry *fwd = (struct TCPFwdEntry*)iter->item;
 		if (!fwd->have_reply) {
 			fwd->have_reply = 1;
-			dropbear_log(LOG_WARNING, "Remote TCP forward request failed (port %d -> %s:%d)", fwd->listenport, fwd->connectaddr, fwd->connectport);
+			fwd_failed("Remote TCP forward request failed (port %d -> %s:%d)",
+					fwd->listenport,
+					fwd->connectaddr,
+					fwd->connectport);
 			return;
 		}
 	}
diff --git a/dbclient.1 b/dbclient.1
index d9e7631ccfec5e7ba0177c12808748959ae9ee45..cd6b5c7fc1ff1c9607957721d472bbcc656566bc 100644
--- a/dbclient.1
+++ b/dbclient.1
@@ -127,6 +127,20 @@ Specify a comma separated list of ciphers to enable. Use \fI-c help\fR to list p
 .B \-m \fIMAClist
 Specify a comma separated list of authentication MACs to enable. Use \fI-m help\fR to list possibilities.
 .TP
+.B \-o \fIoption
+Can be used to give options in the format used by OpenSSH config file. This is
+useful for specifying options for which there is no separate command-line flag.
+For full details of the options listed below, and their possible values, see
+ssh_config(5).
+
+For now only following options have been implemented:
+.RS
+.RS
+.TP
+ExitOnForwardFailure
+.RE
+.RE
+.TP
 .B \-s 
 The specified command will be requested as a subsystem, used for sftp. Dropbear doesn't implement sftp itself but the OpenSSH sftp client can be used eg \fIsftp -S dbclient user@host\fR
 .TP
diff --git a/runopts.h b/runopts.h
index 62c9bf1747fd89df14153284c97ab565f50f81b9..4870c9c2916cb648351ac791e3c0a454143cc4d2 100644
--- a/runopts.h
+++ b/runopts.h
@@ -139,6 +139,9 @@ typedef struct cli_runopts {
 #ifdef ENABLE_CLI_PUBKEY_AUTH
 	m_list *privkeys; /* Keys to use for public-key auth */
 #endif
+#ifdef ENABLE_CLI_ANYTCPFWD
+	int exit_on_fwd_failure;
+#endif
 #ifdef ENABLE_CLI_REMOTETCPFWD
 	m_list * remotefwds;
 #endif