2 * Author: Tatu Ylonen <ylo@cs.hut.fi>
3 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
5 * Created: Sat Mar 18 16:36:11 1995 ylo
6 * Ssh client program. This program can be used to log into a remote machine.
7 * The software supports strong authentication, encryption, and forwarding
8 * of X11, TCP/IP, and authentication connections.
10 * Modified to work with SSL by Niels Provos <provos@citi.umich.edu> in Canada.
28 #ifdef HAVE___PROGNAME
29 extern char *__progname;
30 #else /* HAVE___PROGNAME */
31 const char *__progname = "ssh";
32 #endif /* HAVE___PROGNAME */
34 /* Flag indicating whether IPv4 or IPv6. This can be set on the command line.
35 Default value is AF_UNSPEC means both IPv4 and IPv6. */
37 int IPv4or6 = AF_INET;
39 int IPv4or6 = AF_UNSPEC;
42 /* Flag indicating whether debug mode is on. This can be set on the command line. */
45 /* Flag indicating whether a tty should be allocated */
48 /* don't exec a shell */
49 int no_shell_flag = 0;
53 * Flag indicating that nothing should be read from stdin. This can be set
54 * on the command line.
56 int stdin_null_flag = 0;
59 * Flag indicating that ssh should fork after authentication. This is useful
60 * so that the pasphrase can be entered manually, and then ssh goes to the
63 int fork_after_authentication_flag = 0;
66 * General data structure for command line options and options configurable
67 * in configuration files. See readconf.h.
72 * Name of the host we are connecting to. This is the name given on the
73 * command line, or the HostName specified for the user-supplied name in a
78 /* socket address the host resolves to */
79 struct sockaddr_storage hostaddr;
82 * Flag to indicate that we have received a window change signal which has
83 * not yet been processed. This will cause a message indicating the new
84 * window size to be sent to the server a little later. This is volatile
85 * because this is updated in a signal handler.
87 volatile int received_window_change_signal = 0;
89 /* Value of argv[0] (set in the main program). */
92 /* Flag indicating whether we have a valid host private key loaded. */
93 int host_private_key_loaded = 0;
95 /* Host private key. */
96 RSA *host_private_key = NULL;
98 /* Original real UID. */
99 uid_t original_real_uid;
101 /* command to be executed */
104 /* Prints a help message to the user. This function never returns. */
109 fprintf(stderr, "Usage: %s [options] host [command]\n", av0);
110 fprintf(stderr, "Options:\n");
111 fprintf(stderr, " -l user Log in using this user name.\n");
112 fprintf(stderr, " -n Redirect input from /dev/null.\n");
113 fprintf(stderr, " -a Disable authentication agent forwarding.\n");
115 fprintf(stderr, " -k Disable Kerberos ticket and AFS token forwarding.\n");
117 fprintf(stderr, " -x Disable X11 connection forwarding.\n");
118 fprintf(stderr, " -i file Identity for RSA authentication (default: ~/.ssh/identity).\n");
119 fprintf(stderr, " -t Tty; allocate a tty even if command is given.\n");
120 fprintf(stderr, " -T Do not allocate a tty.\n");
121 fprintf(stderr, " -v Verbose; display verbose debugging messages.\n");
122 fprintf(stderr, " -V Display version number only.\n");
123 fprintf(stderr, " -P Don't allocate a privileged port.\n");
124 fprintf(stderr, " -q Quiet; don't display any warning messages.\n");
125 fprintf(stderr, " -f Fork into background after authentication.\n");
126 fprintf(stderr, " -e char Set escape character; ``none'' = disable (default: ~).\n");
128 fprintf(stderr, " -c cipher Select encryption algorithm: "
131 fprintf(stderr, " -p port Connect to this port. Server must be on the same port.\n");
132 fprintf(stderr, " -L listen-port:host:port Forward local port to remote address\n");
133 fprintf(stderr, " -R listen-port:host:port Forward remote port to local address\n");
134 fprintf(stderr, " These cause %s to listen for connections on a port, and\n", av0);
135 fprintf(stderr, " forward them to the other side by connecting to host:port.\n");
136 fprintf(stderr, " -C Enable compression.\n");
137 fprintf(stderr, " -N Do not execute a shell or command.\n");
138 fprintf(stderr, " -g Allow remote hosts to connect to forwarded ports.\n");
139 fprintf(stderr, " -4 Use IPv4 only.\n");
140 fprintf(stderr, " -6 Use IPv6 only.\n");
141 fprintf(stderr, " -2 Force protocol version 2.\n");
142 fprintf(stderr, " -o 'option' Process the option as if it was read from a configuration file.\n");
147 * Connects to the given host using rsh (or prints an error message and exits
148 * if rsh is not available). This function never returns.
151 rsh_connect(char *host, char *user, Buffer * command)
156 log("Using rsh. WARNING: Connection will not be encrypted.");
157 /* Build argument list for rsh. */
159 args[i++] = _PATH_RSH;
160 /* host may have to come after user on some systems */
166 if (buffer_len(command) > 0) {
167 buffer_append(command, "\0", 1);
168 args[i++] = buffer_ptr(command);
172 for (i = 0; args[i]; i++) {
174 fprintf(stderr, " ");
175 fprintf(stderr, "%s", args[i]);
177 fprintf(stderr, "\n");
179 execv(_PATH_RSH, args);
184 int ssh_session(void);
185 int ssh_session2(void);
188 * Main program for the ssh client.
191 main(int ac, char **av)
193 int i, opt, optind, exit_status, ok;
194 u_short fwd_port, fwd_host_port;
195 char *optarg, *cp, buf[256];
197 struct passwd *pw, pwcopy;
199 uid_t original_effective_uid;
202 * Save the original real uid. It will be needed later (uid-swapping
203 * may clobber the real uid).
205 original_real_uid = getuid();
206 original_effective_uid = geteuid();
208 /* If we are installed setuid root be careful to not drop core. */
209 if (original_real_uid != original_effective_uid) {
211 rlim.rlim_cur = rlim.rlim_max = 0;
212 if (setrlimit(RLIMIT_CORE, &rlim) < 0)
213 fatal("setrlimit failed: %.100s", strerror(errno));
216 * Use uid-swapping to give up root privileges for the duration of
217 * option processing. We will re-instantiate the rights when we are
218 * ready to create the privileged port, and will permanently drop
219 * them when the port has been created (actually, when the connection
220 * has been made, as we may need to create the port several times).
222 temporarily_use_uid(original_real_uid);
225 * Set our umask to something reasonable, as some files are created
226 * with the default umask. This will make them world-readable but
227 * writable only by the owner, which is ok for all files for which we
228 * don't set the modes explicitly.
232 /* Save our own name. */
235 /* Initialize option structure to indicate that no values have been set. */
236 initialize_options(&options);
238 /* Parse command-line arguments. */
241 /* If program name is not one of the standard names, use it as host name. */
242 if (strchr(av0, '/'))
243 cp = strrchr(av0, '/') + 1;
246 if (strcmp(cp, "rsh") != 0 && strcmp(cp, "ssh") != 0 &&
247 strcmp(cp, "rlogin") != 0 && strcmp(cp, "slogin") != 0)
250 for (optind = 1; optind < ac; optind++) {
251 if (av[optind][0] != '-') {
254 if ((cp = strchr(av[optind], '@'))) {
257 options.user = av[optind];
267 if (strchr("eilcpLRo", opt)) { /* options with arguments */
268 optarg = av[optind] + 2;
269 if (strcmp(optarg, "") == 0) {
270 if (optind >= ac - 1)
272 optarg = av[++optind];
281 options.protocol = SSH_PROTO_2;
293 fork_after_authentication_flag = 1;
297 options.forward_x11 = 0;
300 options.forward_x11 = 1;
303 options.gateway_ports = 1;
306 options.use_privileged_port = 0;
309 options.forward_agent = 0;
313 options.kerberos_tgt_passing = 0;
314 options.afs_token_passing = 0;
318 if (stat(optarg, &st) < 0) {
319 fprintf(stderr, "Warning: Identity file %s does not exist.\n",
323 if (options.num_identity_files >= SSH_MAX_IDENTITY_FILES)
324 fatal("Too many identity files specified (max %d)",
325 SSH_MAX_IDENTITY_FILES);
326 options.identity_files[options.num_identity_files++] =
334 fprintf(stderr, "SSH Version %s, protocol versions %d.%d/%d.%d.\n",
336 PROTOCOL_MAJOR_1, PROTOCOL_MINOR_1,
337 PROTOCOL_MAJOR_2, PROTOCOL_MINOR_2);
338 fprintf(stderr, "Compiled with SSL (0x%8.8lx).\n", SSLeay());
342 options.log_level = SYSLOG_LEVEL_DEBUG;
345 options.log_level = SYSLOG_LEVEL_QUIET;
348 if (optarg[0] == '^' && optarg[2] == 0 &&
349 (unsigned char) optarg[1] >= 64 && (unsigned char) optarg[1] < 128)
350 options.escape_char = (unsigned char) optarg[1] & 31;
351 else if (strlen(optarg) == 1)
352 options.escape_char = (unsigned char) optarg[0];
353 else if (strcmp(optarg, "none") == 0)
354 options.escape_char = -2;
356 fprintf(stderr, "Bad escape character '%s'.\n", optarg);
361 options.cipher = cipher_number(optarg);
362 if (options.cipher == -1) {
363 fprintf(stderr, "Unknown cipher type '%s'\n", optarg);
368 options.port = atoi(optarg);
371 options.user = optarg;
374 if (sscanf(optarg, "%hu/%255[^/]/%hu", &fwd_port, buf,
375 &fwd_host_port) != 3 &&
376 sscanf(optarg, "%hu:%255[^:]:%hu", &fwd_port, buf,
377 &fwd_host_port) != 3) {
378 fprintf(stderr, "Bad forwarding specification '%s'.\n", optarg);
382 add_remote_forward(&options, fwd_port, buf, fwd_host_port);
385 if (sscanf(optarg, "%hu/%255[^/]/%hu", &fwd_port, buf,
386 &fwd_host_port) != 3 &&
387 sscanf(optarg, "%hu:%255[^:]:%hu", &fwd_port, buf,
388 &fwd_host_port) != 3) {
389 fprintf(stderr, "Bad forwarding specification '%s'.\n", optarg);
393 add_local_forward(&options, fwd_port, buf, fwd_host_port);
396 options.compression = 1;
407 if (process_config_line(&options, host ? host : "", optarg,
408 "command-line", 0, &dummy) != 0)
416 /* Check that we got a host name. */
420 /* check if RSA support exists */
421 if (rsa_alive() == 0) {
423 "%s: no RSA support in libssl and libcrypto. See ssl(8).\n",
427 /* Initialize the command to execute on remote host. */
428 buffer_init(&command);
431 * Save the command to execute on the remote host in a buffer. There
432 * is no limit on the length of the command, except by the maximum
433 * packet size. Also sets the tty flag if there is no command.
436 /* No command specified - execute shell on a tty. */
439 /* A command has been specified. Store it into the
441 for (i = optind; i < ac; i++) {
443 buffer_append(&command, " ", 1);
444 buffer_append(&command, av[i], strlen(av[i]));
448 /* Cannot fork to background if no command. */
449 if (fork_after_authentication_flag && buffer_len(&command) == 0)
450 fatal("Cannot fork into background without a command to execute.");
452 /* Allocate a tty by default if no command specified. */
453 if (buffer_len(&command) == 0)
456 /* Do not allocate a tty if stdin is not a tty. */
457 if (!isatty(fileno(stdin))) {
459 fprintf(stderr, "Pseudo-terminal will not be allocated because stdin is not a terminal.\n");
467 pw = getpwuid(original_real_uid);
469 fprintf(stderr, "You don't exist, go away!\n");
472 /* Take a copy of the returned structure. */
473 memset(&pwcopy, 0, sizeof(pwcopy));
474 pwcopy.pw_name = xstrdup(pw->pw_name);
475 pwcopy.pw_passwd = xstrdup(pw->pw_passwd);
476 pwcopy.pw_uid = pw->pw_uid;
477 pwcopy.pw_gid = pw->pw_gid;
478 pwcopy.pw_dir = xstrdup(pw->pw_dir);
479 pwcopy.pw_shell = xstrdup(pw->pw_shell);
482 /* Initialize "log" output. Since we are the client all output
483 actually goes to the terminal. */
484 log_init(av[0], options.log_level, SYSLOG_FACILITY_USER, 0);
486 /* Read per-user configuration file. */
487 snprintf(buf, sizeof buf, "%.100s/%.100s", pw->pw_dir, SSH_USER_CONFFILE);
488 read_config_file(buf, host, &options);
490 /* Read systemwide configuration file. */
491 read_config_file(HOST_CONFIG_FILE, host, &options);
493 /* Fill configuration defaults. */
494 fill_default_options(&options);
497 log_init(av[0], options.log_level, SYSLOG_FACILITY_USER, 0);
499 if (options.user == NULL)
500 options.user = xstrdup(pw->pw_name);
502 if (options.hostname != NULL)
503 host = options.hostname;
505 /* Find canonic host name. */
506 if (strchr(host, '.') == 0) {
507 struct addrinfo hints;
508 struct addrinfo *ai = NULL;
510 memset(&hints, 0, sizeof(hints));
511 hints.ai_family = IPv4or6;
512 hints.ai_flags = AI_CANONNAME;
513 hints.ai_socktype = SOCK_STREAM;
514 errgai = getaddrinfo(host, NULL, &hints, &ai);
516 if (ai->ai_canonname != NULL)
517 host = xstrdup(ai->ai_canonname);
521 /* Disable rhosts authentication if not running as root. */
522 if (original_effective_uid != 0 || !options.use_privileged_port) {
523 options.rhosts_authentication = 0;
524 options.rhosts_rsa_authentication = 0;
527 * If using rsh has been selected, exec it now (without trying
528 * anything else). Note that we must release privileges first.
530 if (options.use_rsh) {
532 * Restore our superuser privileges. This must be done
533 * before permanently setting the uid.
537 /* Switch to the original uid permanently. */
538 permanently_set_uid(original_real_uid);
541 rsh_connect(host, options.user, &command);
542 fatal("rsh_connect returned");
544 /* Restore our superuser privileges. */
548 * Open a connection to the remote host. This needs root privileges
549 * if rhosts_{rsa_}authentication is enabled.
552 ok = ssh_connect(host, &hostaddr, options.port,
553 options.connection_attempts,
554 !options.rhosts_authentication &&
555 !options.rhosts_rsa_authentication,
557 options.proxy_command);
560 * If we successfully made the connection, load the host private key
561 * in case we will need it later for combined rsa-rhosts
562 * authentication. This must be done before releasing extra
563 * privileges, because the file is only readable by root.
566 host_private_key = RSA_new();
567 if (load_private_key(HOST_KEY_FILE, "", host_private_key, NULL))
568 host_private_key_loaded = 1;
571 * Get rid of any extra privileges that we may have. We will no
572 * longer need them. Also, extra privileges could make it very hard
573 * to read identity files and other non-world-readable files from the
574 * user's home directory if it happens to be on a NFS volume where
575 * root is mapped to nobody.
579 * Note that some legacy systems need to postpone the following call
580 * to permanently_set_uid() until the private hostkey is destroyed
581 * with RSA_free(). Otherwise the calling user could ptrace() the
582 * process, read the private hostkey and impersonate the host.
583 * OpenBSD does not allow ptracing of setuid processes.
585 permanently_set_uid(original_real_uid);
588 * Now that we are back to our own permissions, create ~/.ssh
589 * directory if it doesn\'t already exist.
591 snprintf(buf, sizeof buf, "%.100s/%.100s", pw->pw_dir, SSH_USER_DIR);
592 if (stat(buf, &st) < 0)
593 if (mkdir(buf, 0755) < 0)
594 error("Could not create directory '%.200s'.", buf);
596 /* Check if the connection failed, and try "rsh" if appropriate. */
598 if (options.port != 0)
599 log("Secure connection to %.100s on port %hu refused%.100s.",
601 options.fallback_to_rsh ? "; reverting to insecure method" : "");
603 log("Secure connection to %.100s refused%.100s.", host,
604 options.fallback_to_rsh ? "; reverting to insecure method" : "");
606 if (options.fallback_to_rsh) {
607 rsh_connect(host, options.user, &command);
608 fatal("rsh_connect returned");
612 /* Expand ~ in options.identity_files. */
613 for (i = 0; i < options.num_identity_files; i++)
614 options.identity_files[i] =
615 tilde_expand_filename(options.identity_files[i], original_real_uid);
617 /* Expand ~ in known host file names. */
618 options.system_hostfile = tilde_expand_filename(options.system_hostfile,
620 options.user_hostfile = tilde_expand_filename(options.user_hostfile,
623 /* Log into the remote system. This never returns if the login fails. */
624 ssh_login(host_private_key_loaded, host_private_key,
625 host, (struct sockaddr *)&hostaddr, original_real_uid);
627 /* We no longer need the host private key. Clear it now. */
628 if (host_private_key_loaded)
629 RSA_free(host_private_key); /* Destroys contents safely */
631 exit_status = compat20 ? ssh_session2() : ssh_session();
648 /* Enable compression if requested. */
649 if (options.compression) {
650 debug("Requesting compression at level %d.", options.compression_level);
652 if (options.compression_level < 1 || options.compression_level > 9)
653 fatal("Compression level must be from 1 (fast) to 9 (slow, best).");
655 /* Send the request. */
656 packet_start(SSH_CMSG_REQUEST_COMPRESSION);
657 packet_put_int(options.compression_level);
660 type = packet_read(&plen);
661 if (type == SSH_SMSG_SUCCESS)
662 packet_start_compression(options.compression_level);
663 else if (type == SSH_SMSG_FAILURE)
664 log("Warning: Remote host refused compression.");
666 packet_disconnect("Protocol error waiting for compression response.");
668 /* Allocate a pseudo tty if appropriate. */
670 debug("Requesting pty.");
672 /* Start the packet. */
673 packet_start(SSH_CMSG_REQUEST_PTY);
675 /* Store TERM in the packet. There is no limit on the
676 length of the string. */
680 packet_put_string(cp, strlen(cp));
682 /* Store window size in the packet. */
683 if (ioctl(fileno(stdin), TIOCGWINSZ, &ws) < 0)
684 memset(&ws, 0, sizeof(ws));
685 packet_put_int(ws.ws_row);
686 packet_put_int(ws.ws_col);
687 packet_put_int(ws.ws_xpixel);
688 packet_put_int(ws.ws_ypixel);
690 /* Store tty modes in the packet. */
691 tty_make_modes(fileno(stdin));
693 /* Send the packet, and wait for it to leave. */
697 /* Read response from the server. */
698 type = packet_read(&plen);
699 if (type == SSH_SMSG_SUCCESS) {
702 } else if (type == SSH_SMSG_FAILURE)
703 log("Warning: Remote host failed or refused to allocate a pseudo tty.");
705 packet_disconnect("Protocol error waiting for pty request response.");
707 /* Request X11 forwarding if enabled and DISPLAY is set. */
708 if (options.forward_x11 && getenv("DISPLAY") != NULL) {
709 char line[512], proto[512], data[512];
711 int forwarded = 0, got_data = 0, i;
714 /* Try to get Xauthority information for the display. */
715 snprintf(line, sizeof line, "%.100s list %.200s 2>/dev/null",
716 XAUTH_PATH, getenv("DISPLAY"));
717 f = popen(line, "r");
718 if (f && fgets(line, sizeof(line), f) &&
719 sscanf(line, "%*s %s %s", proto, data) == 2)
723 #endif /* XAUTH_PATH */
725 * If we didn't get authentication data, just make up some
726 * data. The forwarding code will check the validity of the
727 * response anyway, and substitute this data. The X11
728 * server, however, will ignore this fake data and use
729 * whatever authentication mechanisms it was using otherwise
730 * for the local connection.
735 strlcpy(proto, "MIT-MAGIC-COOKIE-1", sizeof proto);
736 for (i = 0; i < 16; i++) {
739 snprintf(data + 2 * i, sizeof data - 2 * i, "%02x", rand & 0xff);
744 * Got local authentication reasonable information. Request
745 * forwarding with authentication spoofing.
747 debug("Requesting X11 forwarding with authentication spoofing.");
748 x11_request_forwarding_with_spoofing(proto, data);
750 /* Read response from the server. */
751 type = packet_read(&plen);
752 if (type == SSH_SMSG_SUCCESS) {
755 } else if (type == SSH_SMSG_FAILURE)
756 log("Warning: Remote host denied X11 forwarding.");
758 packet_disconnect("Protocol error waiting for X11 forwarding");
760 /* Tell the packet module whether this is an interactive session. */
761 packet_set_interactive(interactive, options.keepalives);
763 /* Clear agent forwarding if we don\'t have an agent. */
764 authfd = ssh_get_authentication_socket();
766 options.forward_agent = 0;
768 ssh_close_authentication_socket(authfd);
770 /* Request authentication agent forwarding if appropriate. */
771 if (options.forward_agent) {
772 debug("Requesting authentication agent forwarding.");
773 auth_request_forwarding();
775 /* Read response from the server. */
776 type = packet_read(&plen);
777 packet_integrity_check(plen, 0, type);
778 if (type != SSH_SMSG_SUCCESS)
779 log("Warning: Remote host denied authentication agent forwarding.");
781 /* Initiate local TCP/IP port forwardings. */
782 for (i = 0; i < options.num_local_forwards; i++) {
783 debug("Connections to local port %d forwarded to remote address %.200s:%d",
784 options.local_forwards[i].port,
785 options.local_forwards[i].host,
786 options.local_forwards[i].host_port);
787 channel_request_local_forwarding(options.local_forwards[i].port,
788 options.local_forwards[i].host,
789 options.local_forwards[i].host_port,
790 options.gateway_ports);
793 /* Initiate remote TCP/IP port forwardings. */
794 for (i = 0; i < options.num_remote_forwards; i++) {
795 debug("Connections to remote port %d forwarded to local address %.200s:%d",
796 options.remote_forwards[i].port,
797 options.remote_forwards[i].host,
798 options.remote_forwards[i].host_port);
799 channel_request_remote_forwarding(options.remote_forwards[i].port,
800 options.remote_forwards[i].host,
801 options.remote_forwards[i].host_port);
804 /* If requested, let ssh continue in the background. */
805 if (fork_after_authentication_flag)
806 if (daemon(1, 1) < 0)
807 fatal("daemon() failed: %.200s", strerror(errno));
810 * If a command was specified on the command line, execute the
811 * command now. Otherwise request the server to start a shell.
813 if (buffer_len(&command) > 0) {
814 int len = buffer_len(&command);
817 debug("Sending command: %.*s", len, buffer_ptr(&command));
818 packet_start(SSH_CMSG_EXEC_CMD);
819 packet_put_string(buffer_ptr(&command), buffer_len(&command));
823 debug("Requesting shell.");
824 packet_start(SSH_CMSG_EXEC_SHELL);
829 /* Enter the interactive session. */
830 return client_loop(have_tty, tty_flag ? options.escape_char : -1);
837 /* Initiate local TCP/IP port forwardings. */
838 for (i = 0; i < options.num_local_forwards; i++) {
839 debug("Connections to local port %d forwarded to remote address %.200s:%d",
840 options.local_forwards[i].port,
841 options.local_forwards[i].host,
842 options.local_forwards[i].host_port);
843 channel_request_local_forwarding(options.local_forwards[i].port,
844 options.local_forwards[i].host,
845 options.local_forwards[i].host_port,
846 options.gateway_ports);
850 extern void client_set_session_ident(int id);
853 client_init(int id, void *arg)
856 debug("client_init id %d arg %d", id, (int)arg);
867 /* Store window size in the packet. */
868 if (ioctl(fileno(stdin), TIOCGWINSZ, &ws) < 0)
869 memset(&ws, 0, sizeof(ws));
871 channel_request_start(id, "pty-req", 0);
872 packet_put_cstring(cp);
873 packet_put_int(ws.ws_col);
874 packet_put_int(ws.ws_row);
875 packet_put_int(ws.ws_xpixel);
876 packet_put_int(ws.ws_ypixel);
877 packet_put_cstring(""); /* XXX: encode terminal modes */
879 /* XXX wait for reply */
881 len = buffer_len(&command);
885 debug("Sending command: %.*s", len, buffer_ptr(&command));
886 channel_request_start(id, "exec", 0);
887 packet_put_string(buffer_ptr(&command), len);
890 channel_request(id, "shell", 0);
892 /* channel_callback(id, SSH2_MSG_OPEN_CONFIGMATION, client_init, 0); */
894 /* register different callback, etc. XXX */
895 client_set_session_ident(id);
901 int window, packetmax, id;
902 int in = dup(STDIN_FILENO);
903 int out = dup(STDOUT_FILENO);
904 int err = dup(STDERR_FILENO);
906 if (in < 0 || out < 0 || err < 0)
907 fatal("dump in/out/err failed");
909 /* should be pre-session */
914 packetmax = window/8;
917 packetmax = window/2;
921 "session", SSH_CHANNEL_OPENING, in, out, err,
922 window, packetmax, CHAN_EXTENDED_WRITE, xstrdup("client-session"));
926 channel_register_callback(id, SSH2_MSG_CHANNEL_OPEN_CONFIRMATION, client_init, (void *)0);
928 return client_loop(tty_flag, tty_flag ? options.escape_char : -1);