summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--readconf.c13
-rw-r--r--readconf.h3
-rw-r--r--ssh.15
-rw-r--r--ssh.c40
-rw-r--r--ssh_config.512
5 files changed, 58 insertions, 15 deletions
diff --git a/readconf.c b/readconf.c
index 4be5327a9..b11c628f9 100644
--- a/readconf.c
+++ b/readconf.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: readconf.c,v 1.276 2017/05/20 02:35:47 djm Exp $ */ 1/* $OpenBSD: readconf.c,v 1.277 2017/05/30 18:58:37 bluhm Exp $ */
2/* 2/*
3 * Author: Tatu Ylonen <ylo@cs.hut.fi> 3 * Author: Tatu Ylonen <ylo@cs.hut.fi>
4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -163,7 +163,8 @@ typedef enum {
163 oServerAliveInterval, oServerAliveCountMax, oIdentitiesOnly, 163 oServerAliveInterval, oServerAliveCountMax, oIdentitiesOnly,
164 oSendEnv, oControlPath, oControlMaster, oControlPersist, 164 oSendEnv, oControlPath, oControlMaster, oControlPersist,
165 oHashKnownHosts, 165 oHashKnownHosts,
166 oTunnel, oTunnelDevice, oLocalCommand, oPermitLocalCommand, 166 oTunnel, oTunnelDevice,
167 oLocalCommand, oPermitLocalCommand, oRemoteCommand,
167 oVisualHostKey, 168 oVisualHostKey,
168 oKexAlgorithms, oIPQoS, oRequestTTY, oIgnoreUnknown, oProxyUseFdpass, 169 oKexAlgorithms, oIPQoS, oRequestTTY, oIgnoreUnknown, oProxyUseFdpass,
169 oCanonicalDomains, oCanonicalizeHostname, oCanonicalizeMaxDots, 170 oCanonicalDomains, oCanonicalizeHostname, oCanonicalizeMaxDots,
@@ -284,6 +285,7 @@ static struct {
284 { "tunneldevice", oTunnelDevice }, 285 { "tunneldevice", oTunnelDevice },
285 { "localcommand", oLocalCommand }, 286 { "localcommand", oLocalCommand },
286 { "permitlocalcommand", oPermitLocalCommand }, 287 { "permitlocalcommand", oPermitLocalCommand },
288 { "remotecommand", oRemoteCommand },
287 { "visualhostkey", oVisualHostKey }, 289 { "visualhostkey", oVisualHostKey },
288 { "kexalgorithms", oKexAlgorithms }, 290 { "kexalgorithms", oKexAlgorithms },
289 { "ipqos", oIPQoS }, 291 { "ipqos", oIPQoS },
@@ -1440,6 +1442,10 @@ parse_keytypes:
1440 intptr = &options->permit_local_command; 1442 intptr = &options->permit_local_command;
1441 goto parse_flag; 1443 goto parse_flag;
1442 1444
1445 case oRemoteCommand:
1446 charptr = &options->remote_command;
1447 goto parse_command;
1448
1443 case oVisualHostKey: 1449 case oVisualHostKey:
1444 intptr = &options->visual_host_key; 1450 intptr = &options->visual_host_key;
1445 goto parse_flag; 1451 goto parse_flag;
@@ -1828,6 +1834,7 @@ initialize_options(Options * options)
1828 options->tun_remote = -1; 1834 options->tun_remote = -1;
1829 options->local_command = NULL; 1835 options->local_command = NULL;
1830 options->permit_local_command = -1; 1836 options->permit_local_command = -1;
1837 options->remote_command = NULL;
1831 options->add_keys_to_agent = -1; 1838 options->add_keys_to_agent = -1;
1832 options->identity_agent = NULL; 1839 options->identity_agent = NULL;
1833 options->visual_host_key = -1; 1840 options->visual_host_key = -1;
@@ -2032,6 +2039,7 @@ fill_default_options(Options * options)
2032 } \ 2039 } \
2033 } while(0) 2040 } while(0)
2034 CLEAR_ON_NONE(options->local_command); 2041 CLEAR_ON_NONE(options->local_command);
2042 CLEAR_ON_NONE(options->remote_command);
2035 CLEAR_ON_NONE(options->proxy_command); 2043 CLEAR_ON_NONE(options->proxy_command);
2036 CLEAR_ON_NONE(options->control_path); 2044 CLEAR_ON_NONE(options->control_path);
2037 CLEAR_ON_NONE(options->revoked_host_keys); 2045 CLEAR_ON_NONE(options->revoked_host_keys);
@@ -2509,6 +2517,7 @@ dump_client_config(Options *o, const char *host)
2509 dump_cfg_string(oKbdInteractiveDevices, o->kbd_interactive_devices); 2517 dump_cfg_string(oKbdInteractiveDevices, o->kbd_interactive_devices);
2510 dump_cfg_string(oKexAlgorithms, o->kex_algorithms ? o->kex_algorithms : KEX_CLIENT_KEX); 2518 dump_cfg_string(oKexAlgorithms, o->kex_algorithms ? o->kex_algorithms : KEX_CLIENT_KEX);
2511 dump_cfg_string(oLocalCommand, o->local_command); 2519 dump_cfg_string(oLocalCommand, o->local_command);
2520 dump_cfg_string(oRemoteCommand, o->remote_command);
2512 dump_cfg_string(oLogLevel, log_level_name(o->log_level)); 2521 dump_cfg_string(oLogLevel, log_level_name(o->log_level));
2513 dump_cfg_string(oMacs, o->macs ? o->macs : KEX_CLIENT_MAC); 2522 dump_cfg_string(oMacs, o->macs ? o->macs : KEX_CLIENT_MAC);
2514#ifdef ENABLE_PKCS11 2523#ifdef ENABLE_PKCS11
diff --git a/readconf.h b/readconf.h
index f47f53402..94dd427f5 100644
--- a/readconf.h
+++ b/readconf.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: readconf.h,v 1.121 2017/04/30 23:18:22 djm Exp $ */ 1/* $OpenBSD: readconf.h,v 1.122 2017/05/30 18:58:37 bluhm Exp $ */
2 2
3/* 3/*
4 * Author: Tatu Ylonen <ylo@cs.hut.fi> 4 * Author: Tatu Ylonen <ylo@cs.hut.fi>
@@ -134,6 +134,7 @@ typedef struct {
134 134
135 char *local_command; 135 char *local_command;
136 int permit_local_command; 136 int permit_local_command;
137 char *remote_command;
137 int visual_host_key; 138 int visual_host_key;
138 139
139 int request_tty; 140 int request_tty;
diff --git a/ssh.1 b/ssh.1
index 10633d92b..47cd0211d 100644
--- a/ssh.1
+++ b/ssh.1
@@ -33,8 +33,8 @@
33.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 33.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
34.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35.\" 35.\"
36.\" $OpenBSD: ssh.1,v 1.381 2017/05/05 10:41:58 naddy Exp $ 36.\" $OpenBSD: ssh.1,v 1.382 2017/05/30 18:58:37 bluhm Exp $
37.Dd $Mdocdate: May 5 2017 $ 37.Dd $Mdocdate: May 30 2017 $
38.Dt SSH 1 38.Dt SSH 1
39.Os 39.Os
40.Sh NAME 40.Sh NAME
@@ -518,6 +518,7 @@ For full details of the options listed below, and their possible values, see
518.It PubkeyAcceptedKeyTypes 518.It PubkeyAcceptedKeyTypes
519.It PubkeyAuthentication 519.It PubkeyAuthentication
520.It RekeyLimit 520.It RekeyLimit
521.It RemoteCommand
521.It RemoteForward 522.It RemoteForward
522.It RequestTTY 523.It RequestTTY
523.It SendEnv 524.It SendEnv
diff --git a/ssh.c b/ssh.c
index cfd6b70e5..6137fd7da 100644
--- a/ssh.c
+++ b/ssh.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssh.c,v 1.460 2017/05/30 08:52:19 markus Exp $ */ 1/* $OpenBSD: ssh.c,v 1.461 2017/05/30 18:58:37 bluhm Exp $ */
2/* 2/*
3 * Author: Tatu Ylonen <ylo@cs.hut.fi> 3 * Author: Tatu Ylonen <ylo@cs.hut.fi>
4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -973,12 +973,6 @@ main(int ac, char **av)
973 } 973 }
974 } 974 }
975 975
976 /* Cannot fork to background if no command. */
977 if (fork_after_authentication_flag && buffer_len(&command) == 0 &&
978 !no_shell_flag)
979 fatal("Cannot fork into background without a command "
980 "to execute.");
981
982 /* 976 /*
983 * Initialize "log" output. Since we are the client all output 977 * Initialize "log" output. Since we are the client all output
984 * goes to stderr unless otherwise specified by -y or -E. 978 * goes to stderr unless otherwise specified by -y or -E.
@@ -1133,6 +1127,15 @@ main(int ac, char **av)
1133 options.use_privileged_port = 0; 1127 options.use_privileged_port = 0;
1134#endif 1128#endif
1135 1129
1130 if (buffer_len(&command) != 0 && options.remote_command != NULL)
1131 fatal("Cannot execute command-line and remote command.");
1132
1133 /* Cannot fork to background if no command. */
1134 if (fork_after_authentication_flag && buffer_len(&command) == 0 &&
1135 options.remote_command == NULL && !no_shell_flag)
1136 fatal("Cannot fork into background without a command "
1137 "to execute.");
1138
1136 /* reinit */ 1139 /* reinit */
1137 log_init(argv0, options.log_level, options.log_facility, !use_syslog); 1140 log_init(argv0, options.log_level, options.log_facility, !use_syslog);
1138 1141
@@ -1141,7 +1144,7 @@ main(int ac, char **av)
1141 tty_flag = 1; 1144 tty_flag = 1;
1142 1145
1143 /* Allocate a tty by default if no command specified. */ 1146 /* Allocate a tty by default if no command specified. */
1144 if (buffer_len(&command) == 0) 1147 if (buffer_len(&command) == 0 && options.remote_command == NULL)
1145 tty_flag = options.request_tty != REQUEST_TTY_NO; 1148 tty_flag = options.request_tty != REQUEST_TTY_NO;
1146 1149
1147 /* Force no tty */ 1150 /* Force no tty */
@@ -1197,6 +1200,27 @@ main(int ac, char **av)
1197 free(cp); 1200 free(cp);
1198 } 1201 }
1199 1202
1203 if (options.remote_command != NULL) {
1204 debug3("expanding RemoteCommand: %s", options.remote_command);
1205 cp = options.remote_command;
1206 options.remote_command = percent_expand(cp,
1207 "C", conn_hash_hex,
1208 "L", shorthost,
1209 "d", pw->pw_dir,
1210 "h", host,
1211 "l", thishost,
1212 "n", host_arg,
1213 "p", portstr,
1214 "r", options.user,
1215 "u", pw->pw_name,
1216 (char *)NULL);
1217 debug3("expanded RemoteCommand: %s", options.remote_command);
1218 free(cp);
1219 buffer_append(&command, options.remote_command,
1220 strlen(options.remote_command));
1221
1222 }
1223
1200 if (options.control_path != NULL) { 1224 if (options.control_path != NULL) {
1201 cp = tilde_expand_filename(options.control_path, 1225 cp = tilde_expand_filename(options.control_path,
1202 original_real_uid); 1226 original_real_uid);
diff --git a/ssh_config.5 b/ssh_config.5
index db37b92cd..2c9e20fec 100644
--- a/ssh_config.5
+++ b/ssh_config.5
@@ -33,8 +33,8 @@
33.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 33.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
34.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35.\" 35.\"
36.\" $OpenBSD: ssh_config.5,v 1.248 2017/05/07 23:12:57 djm Exp $ 36.\" $OpenBSD: ssh_config.5,v 1.249 2017/05/30 18:58:37 bluhm Exp $
37.Dd $Mdocdate: May 7 2017 $ 37.Dd $Mdocdate: May 30 2017 $
38.Dt SSH_CONFIG 5 38.Dt SSH_CONFIG 5
39.Os 39.Os
40.Sh NAME 40.Sh NAME
@@ -1287,6 +1287,14 @@ is
1287.Cm default none , 1287.Cm default none ,
1288which means that rekeying is performed after the cipher's default amount 1288which means that rekeying is performed after the cipher's default amount
1289of data has been sent or received and no time based rekeying is done. 1289of data has been sent or received and no time based rekeying is done.
1290.It Cm RemoteCommand
1291Specifies a command to execute on the remote machine after successfully
1292connecting to the server.
1293The command string extends to the end of the line, and is executed with
1294the user's shell.
1295The same escape character substitutions as for
1296.Cm LocalCommand
1297will be performed.
1290.It Cm RemoteForward 1298.It Cm RemoteForward
1291Specifies that a TCP port on the remote machine be forwarded over 1299Specifies that a TCP port on the remote machine be forwarded over
1292the secure channel to the specified host and port from the local machine. 1300the secure channel to the specified host and port from the local machine.