From 70d48fbcc038d4f746bab029e8449812263f2cf9 Mon Sep 17 00:00:00 2001 From: John Hood Date: Sat, 17 May 2014 01:34:14 -0400 Subject: [PATCH] Add --no-ssh-pty option. This eliminates issues with typeahead being echoed by the remote pty and corrupting remote output from mosh-server to the mosh script, but cannot be made default because older mosh-servers require a pty. --- man/mosh.1 | 6 ++++++ scripts/mosh.pl | 10 +++++++++- src/frontend/mosh-server.cc | 2 -- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/man/mosh.1 b/man/mosh.1 index b2e1df0..d163206 100644 --- a/man/mosh.1 +++ b/man/mosh.1 @@ -114,6 +114,12 @@ OpenSSH command to remotely execute mosh-server on remote machine (default: "ssh An alternate ssh port can be specified with, \fIe.g.\fP, \-\-ssh="ssh \-p 2222". +.TP +.B \-\-ssh-pty\fP +.B \-\-no-ssh-pty\fP +Enable or disable ssh's use of a pty when connecting to a remote host. +The default is enabled. + .TP .B \-\-predict=\fIWHEN\fP Controls use of speculative local echo. WHEN defaults to `adaptive' diff --git a/scripts/mosh.pl b/scripts/mosh.pl index 45d5c4c..37eb1ff 100755 --- a/scripts/mosh.pl +++ b/scripts/mosh.pl @@ -72,6 +72,8 @@ my $term_init = 1; my $localhost = undef; +my $ssh_pty = 1; + my $help = undef; my $version = undef; @@ -104,6 +106,8 @@ qq{Usage: $0 [options] [--] [user@]host [command...] (example: "ssh -p 2222") (default: "ssh") + --no-ssh-pty do not allocate a pseudo tty on ssh connection + --no-init do not send terminal initialization string --local run mosh-server locally without using ssh @@ -147,6 +151,7 @@ GetOptions( 'client=s' => \$client, '6' => sub { $family = 'inet6' }, 'p=s' => \$port_request, 'ssh=s' => sub { @ssh = shellwords($_[1]); }, + 'ssh-pty!' => \$ssh_pty, 'init!' => \$term_init, 'local' => \$localhost, 'help' => \$help, @@ -328,7 +333,10 @@ die "$0: fork: $!\n" unless ( defined $pid ); if ( $pid == 0 ) { # child open(STDERR, ">&STDOUT") or die; - my @sshopts = ( '-n', '-tt' ); + my @sshopts = ( '-n' ); + if ($ssh_pty) { + push @sshopts, '-tt'; + } my $ssh_connection = ""; if ( $use_remote_ip eq 'remote' ) { diff --git a/src/frontend/mosh-server.cc b/src/frontend/mosh-server.cc index 976126f..e4c0b55 100644 --- a/src/frontend/mosh-server.cc +++ b/src/frontend/mosh-server.cc @@ -388,8 +388,6 @@ static int run_server( const char *desired_ip, const char *desired_port, if ( ioctl( STDIN_FILENO, TIOCGWINSZ, &window_size ) < 0 || window_size.ws_col == 0 || window_size.ws_row == 0 ) { - fprintf( stderr, "Server started without pseudo-terminal. Opening 80x24 terminal.\n" ); - /* Fill in sensible defaults. */ /* They will be overwritten by client on first connection. */ memset( &window_size, 0, sizeof( window_size ) );