The Perl script 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. If you are searching for an X2Go command-line client, please take a look at the PyHoca-CLI X2Go component.
However, the x2goclient-cli script is very good for studying the X2Go session handshake. It can be found in the ''examples'' folder of x2goclient.git.
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-ssh.
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.