User Tools

Site Tools


wiki:development:x2goclient-cli-study

This is an old revision of the document!


x2goclient-cli

x2goclient-cli was developed for testing purposes, but is still quite usable. There are some advantages over the graphical alternatives, e g easier to start multiple x2go sessions.

There are some issues with it, the biggest problem is that after a session has ended there are still ssh tunnels running between the client and the server. If you then try to connect to a different server it will likely fail with an error message about “the remote proxy closed the connection while negotiating …”, because the local TCP port is still in use on the client.

Using SSH keys to authenticate seems to avoid the problem, see passwordless_authentication_using_ssh-keys.

If you need to use password authentication, add these lines after the last line in x2goclient-cli to mitigate the problem:

my @SSHS = ();
my $ssh;
my $pid;
my @ssh_split = ();
 
# print "$0: Checking ssh sessions ...\n";
open(GR_SSH,"ps ux | grep \"ssh -p $port .*-N -L $gr_port:localhost:$gr_port $user\@$server\" | grep -v grep |");
@SSHS = <GR_SSH>;
close(GR_SSH);
 
if ($sound) {
   open(SND_SSH,"ps ux | grep \"ssh -p $port .*-N -R $snd_port:localhost:$snd_port $user\@$server\" | grep -v grep |");
   push(@SSHS,<SND_SSH>);
   close(SND_SSH);
}
 
if (scalar(@SSHS) > 0) {
   foreach $ssh (@SSHS) {
       $ssh =~ s/\s+/\|/g;
       @ssh_split = split(/\|/,$ssh);
       $pid = $ssh_split[1];
       # print "$0: Ending ssh session with pid $pid ...\n";
       system("kill -1 $pid");
   }
} else {
   # print "$0: No ssh sessions found.\n";
}

The above code will work with both password authentication and SSH keys.

wiki/development/x2goclient-cli-study.1318876892.txt.gz · Last modified: 2013/03/08 13:31 (external edit)