Skip to content

Instantly share code, notes, and snippets.

@jkoop
Last active November 20, 2025 21:49
Show Gist options
  • Select an option

  • Save jkoop/f6a224fbfd1746127f6b85b83581d156 to your computer and use it in GitHub Desktop.

Select an option

Save jkoop/f6a224fbfd1746127f6b85b83581d156 to your computer and use it in GitHub Desktop.
4a5
> # Some changes by Joe Koop 2025
352a354,370
> my @server = ( 'new' );
>
> push @server, ( '-c', $colors );
> push @server, @bind_arguments;
>
> if ( defined $port_request ) {
> push @server, ( '-p', $port_request );
> }
>
> for ( &locale_vars ) {
> push @server, ( '-l', $_ );
> }
>
> if ( scalar @command > 0 ) {
> push @server, '--', @command;
> }
>
377,393d394
< my @server = ( 'new' );
<
< push @server, ( '-c', $colors );
<
< push @server, @bind_arguments;
<
< if ( defined $port_request ) {
< push @server, ( '-p', $port_request );
< }
<
< for ( &locale_vars ) {
< push @server, ( '-l', $_ );
< }
<
< if ( scalar @command > 0 ) {
< push @server, '--', @command;
< }
409c410,414
< my @exec_argv = ( @ssh, @sshopts, $userhost, '--', $ssh_connection . "$server " . shell_quote( @server ) );
---
>
> my $install_server = "sh -c " .
> shell_quote( 'which ' . shell_quote($server) . ' >/dev/null || ( echo "Installing mosh server..."; sudo --non-interactive apt install -y mosh >/dev/stderr </dev/null ); which ufw >/dev/null && ( sudo --non-interactive ufw status | grep -q inactive || sudo --non-interactive ufw status | grep -q mosh || ( echo "Allowing mosh through ufw..."; sudo --non-interactive ufw allow mosh )); test -f ~/.hushlogin || touch ~/.hushlogin ' ) .
> " ; ";
> my @exec_argv = ( @ssh, @sshopts, $userhost, '--', $ssh_connection . $install_server . "$server " . shell_quote( @server ) );
458c463,468
< die "$0: Did not find mosh server startup message. (Have you installed mosh on your server?)\n";
---
> print "Falling back to SSH...\n";
> print "Run this to install mosh server:\n";
> print "\n";
> print 'sudo apt install -y mosh; which ufw >/dev/null && sudo ufw allow mosh' . "\n";
> print "\n";
> exec @ssh, $userhost
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment