Commit f4bf9b5c authored by Leigh Stoller's avatar Leigh Stoller

Commit SSH node menu option, and support. Heavily based/borrowed from

Chad's tiptunnel stuff. Requires ssh-mime.pl in the current directory,
to be installed as a browser helper application on the users machine.
Copied Chad's instructions for the tiptunnel from the FAQ, and stuck
it into ssh-mime.html as a help file (not really FAQ material). The
intent of this of course is to make ssh into jailed nodes easier, but
not having to know port numbers, or directly log into ops first, when
the jails are using control network IPs in our private IP space (not
routable from outside).
parent 5abadac2
......@@ -37,7 +37,7 @@ FILES += $(wildcard $(SRCDIR)/*.html)
FILES += $(wildcard $(SRCDIR)/*.php3)
FILES += $(wildcard $(SRCDIR)/*.php)
FILES += $(wildcard $(SRCDIR)/*.ico)
FILES += $(SRCDIR)/.htaccess $(SRCDIR)/error.shtml
FILES += $(SRCDIR)/.htaccess $(SRCDIR)/error.shtml $(SRCDIR)/ssh-mime.pl
AUTOICONS = $(wildcard $(SRCDIR)/autostatus-icons/*.gif)
AUTOICONS += $(wildcard $(SRCDIR)/autostatus-icons/*.png)
......
......@@ -5,6 +5,7 @@
$TBDIR = "@prefix@/";
$OURDOMAIN = "@OURDOMAIN@";
$BOSSNODE = "@BOSSNODE@";
$USERNODE = "@USERNODE@";
$TBADMINGROUP = "@TBADMINGROUP@";
$WWWHOST = "@WWWHOST@";
$WWW = "@WWW@";
......
<?php
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2003 University of Utah and the Flux Group.
# All rights reserved.
#
include("defs.php3");
#
# This script generates an "tbc" file, to be passed to ./ssh-mime.pl
# on the remote node, when set up as a proper mime type.
#
#
# Only known and logged in users.
#
$uid = GETLOGIN();
LOGGEDINORDIE($uid);
#
# Verify form arguments.
#
if (!isset($node_id) ||
strcmp($node_id, "") == 0) {
USERERROR("You must provide a node ID.", 1);
}
$query_result =
DBQueryFatal("select n.jailflag,n.jailip,n.sshdport, ".
" r.vname,r.pid,r.eid, ".
" t.isvirtnode,t.isremotenode ".
" from nodes as n ".
"left join reserved as r on n.node_id=r.node_id ".
"left join node_types as t on t.type=n.type ".
"where n.node_id='$node_id'");
if (mysql_num_rows($query_result) == 0) {
USERERROR("The node $node_id does not exist!", 1);
}
$row = mysql_fetch_array($query_result);
$jailflag = $row[jailflag];
$jailip = $row[jailip];
$sshdport = $row[sshdport];
$vname = $row[vname];
$pid = $row[pid];
$eid = $row[eid];
$isvirt = $row[isvirtnode];
$isremote = $row[isremotenode];
if (!isset($pid)) {
USERERROR("$node_id is not allocated to an experiment!", 1);
}
$filename = $node_id . ".tbc";
header("Content-Type: text/x-testbed-ssh");
header("Content-Disposition: attachment; filename=$filename;");
header("Content-Description: SSH description file for a testbed node");
echo "hostname: $vname.$eid.$pid.$OURDOMAIN\n";
echo "login: $uid\n";
if ($isvirt) {
if ($isremote) {
#
# Remote nodes run sshd on another port since they so not
# have per-jail IPs. Of course, might not even be jailed!
#
if ($jailflag) {
echo "port: $sshdport\n";
}
}
else {
#
# Local virt nodes are on the private network, so have to
# bounce through ops node to get there. They run sshd on
# on the standard port, but on a private IP.
#
echo "gateway: $USERNODE\n";
}
}
?>
<?php
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2002 University of Utah and the Flux Group.
# Copyright (c) 2000-2003 University of Utah and the Flux Group.
# All rights reserved.
#
include("defs.php3");
......@@ -44,37 +44,33 @@ if (! $isadmin) {
}
}
echo "<font size=+2>".
"Node <b>$node_id</b>";
$query_result = DBQueryFatal("select r.vname,r.pid,r.eid from nodes as n ".
"left join reserved as r on n.node_id=r.node_id ".
"where n.node_id='$node_id'");
if (mysql_num_rows($query_result) != 0) {
$row = mysql_fetch_array($query_result);
$vname = $row[vname];
$pid = $row[pid];
$eid = $row[eid];
if ($vname != "") {
# echo " (<b>".
# "<a href='showproject.php3?pid=$pid'>$pid</a>/".
# "<a href='showexp.php3?pid=$pid&eid=$eid'>$eid</a>/".
# "$vname</b>)";
echo " (<b>".
"$vname.".
"<a href='showexp.php3?pid=$pid&eid=$eid'>$eid</a>.".
"<a href='showproject.php3?pid=$pid'>$pid</a>.".
"$OURDOMAIN".
"</b>)";
$query_result =
DBQueryFatal("select r.vname,r.pid,r.eid from nodes as n ".
"left join reserved as r on n.node_id=r.node_id ".
"where n.node_id='$node_id'");
}
if (! mysql_num_rows($query_result) != 0) {
TBERROR("Node $node id does not have a nodes table entry!", 1);
}
$row = mysql_fetch_array($query_result);
$vname = $row[vname];
$pid = $row[pid];
$eid = $row[eid];
if (isset($pid) && $vname != "") {
echo " (<b>".
" $vname.".
" <a href='showexp.php3?pid=$pid&eid=$eid'>$eid</a>.".
" <a href='showproject.php3?pid=$pid'>$pid</a>.".
" $OURDOMAIN".
" </b>)";
}
echo "</font><br /><br />\n";
echo "</font><br><br>\n";
SUBPAGESTART();
SUBMENUSTART("Node Options");
......@@ -82,13 +78,21 @@ SUBMENUSTART("Node Options");
#
# Tip to node option
#
if (TBHasSerialConsole($node_id) && ($isadmin ||
TBNodeAccessCheck($uid, $node_id, $TB_NODEACCESS_MODIFYINFO))) {
if (TBHasSerialConsole($node_id)) {
WRITESUBMENUBUTTON("Connect to Serial Line</a> " .
"<a href=\"faq.php3#UTT-TUNNEL\">(howto)",
"nodetipacl.php3?node_id=$node_id");
}
#
# SSH to option.
#
if (! strcmp($OURDOMAIN, "mini.emulab.net") && isset($pid)) {
WRITESUBMENUBUTTON("SSH to node</a> ".
"<a href='docwrapper.php3?docname=ssh-mime.html'>".
"(howto)", "nodessh.php3?node_id=$node_id");
}
#
# Edit option
#
......
......@@ -33,12 +33,11 @@ else {
}
#
# Check to make sure thats this is a valid UID.
# Check to make sure thats this is a valid UID. Getting the status works,
# and we need that later.
#
$query_result =
DBQueryFatal("SELECT * FROM users WHERE uid='$target_uid'");
if (mysql_num_rows($query_result) == 0) {
USERERROR("The user $target_uid is not a valid user", 1);
if (! ($userstatus = TBUserStatus($target_uid))) {
USERERROR("The user $target_uid is not a valid user", 1);
}
#
......@@ -174,8 +173,12 @@ if ($isadmin) {
}
WRITESUBMENUBUTTON("Delete User",
"deleteuser.php3?target_uid=$target_uid");
WRITESUBMENUBUTTON("Resend Verification Key",
"resendkey.php3?target_uid=$target_uid");
if (! strcmp($userstatus, TBDB_USERSTATUS_NEWUSER) ||
! strcmp($userstatus, TBDB_USERSTATUS_UNVERIFIED)) {
WRITESUBMENUBUTTON("Resend Verification Key",
"resendkey.php3?target_uid=$target_uid");
}
}
SUBMENUEND();
......
<!--
EMULAB-COPYRIGHT
Copyright (c) 2000-2003 University of Utah and the Flux Group.
All rights reserved.
-->
<center>
<h2>SSH to Node</h2>
</center>
<p>
Clicking "SSH to Node" in the Node Options page will send your browser
a "text/x-testbed-ssh" ".tbc" file. In FreeBSD or Linux, you can save
the file and pass it as an argument to <code>ssh-mime.pl</code> or
associate it with <code>ssh-mime.pl</code> in your web browser. You
can download the <code>ssh-mime.pl </code><a href="ssh-mime.pl">Perl
program here</a>.
</p>
<p>
<font size='+1'><b>Instructions for Linux/FreeBSD:</b></font>
<ul>
<li>Move the <code>ssh-mime.pl</code> script into
a directory of your choice (<code>/usr/local/bin</code>,
or <code>~/bin</code> are two good places.)</li>
<li>Set up your browser to handle MIME type "text/x-testbed-ssh"
as outlined below.</li>
<li>In the Web Interface Node view, click on the "SSH to Node" link.</li>
<li>If your browser is properly configured to use <code>ssh-mime.pl</code>,
a new xterm window with an ssh session open to your node
should emerge.</li>
</ul>
</li>
<ul>
<li><font size='+1'><b>Linux/FreeBSD and Netscape 4.7:</b></font>
<ul>
<li>Choose <code>preferences</code> from the <code>edit</code> menu.</li>
<li>Select <code>Navigator</code>, then <code>Applications</code> under
it.</li>
<li>Click the <code>New...</code> button.</li>
<li>In the <code>MIMEType</code> box, type <code>text/x-testbed-ssh</code>
</li>
<li>In the <code>Suffixes</code> box, type <code>tbc</code></li>
<li>Choose <code>Application</code> in the <code>Handled by</code>
box</li>
<li>Next to <code>Application</code>, either type the path to the
<code>ssh-mime.pl</code> script, or use <code>Choose...</code> to find
it.</li>
<li>Now, <b>be sure to</b> put a space, then <code>%s</code> after the
path to the application in the box. This tells netscape to actually
pass the control file into ssh-mime.pl (Mozilla does not require this;
see below.)</li>
<li>Click <code>OK</code>, then <code>OK</code> again.</li>
</ul>
</li>
<li><font size='+1'><b>Linux/FreeBSD and Mozilla:</b></font>
<ul>
<li>Choose <code>preferences</code> from the <code>edit</code> menu.</li>
<li>Select <code>Navigator</code>, then <code>Helper Applications</code>
under it.</li>
<li>Click the <code>New Type...</code> button.</li>
<li>In the <code>MIMEType</code> box,
type <code>text/x-testbed-ssh</code></li>
<li>In the <code>File extension</code> box, type <code>tbc</code></li>
<li>For <code>Application to use</code>, either type the path to the
<code>ssh-mime.pl</code> script, or use <code>Choose...</code> to find
it.</li>
<li>In Mozilla do <b>not</b> add a <code>%s</code>.</li>
<li>Click <code>OK</code>, then <code>OK</code> again.</li>
</ul>
</li>
<li><font size='+1'><b>Linux/FreeBSD and Opera:</b></font>
<ul>
<li>Choose <code>preferences</code> from the <code>File</code> menu.</li>
<li>Select <code>Applications</code>, then <code>File Types</code>
under it.</li>
<li>Click the <code>New ...</code> button.</li>
<li>In the <code>MIMEType</code> box,
type <code>text/x-testbed-ssh</code></li>
<li>In the <code>File extension</code> box, type <code>tbc</code></li>
<li>For <code>Open with other application</code>, either type the path to
the <code>ssh-mime.pl</code> script, or use <code>Choose...</code> to
find it.</li>
<li>In Opera do <b>not</b> add a <code>%s</code>.</li>
<li>Click <code>OK</code>, then <code>OK</code> again.</li>
</ul>
</li>
</ul>
<font size='+1'><b>Instructions for Windows:</b></font>
<ul>
<li>Sorry, no windows support yet, although the script is really
simple, and should be trivially convertable to a windows batch
file, or even a windows Perl script if you care to install Perl on
your windows machine.
</ul>
</p>
#!/usr/bin/perl -w
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2003 University of Utah and the Flux Group.
# All rights reserved.
#
use English;
use Getopt::Std;
#
# This is a helper program for your web browser. It allows you to ssh
# to an experimental node by clicking on a menu option in the shownode
# page. Its extremely helpful with jailed nodes, where sshd is either
# running on another port, or on a private IP. Please see the Emulab FAQ
# for instructions on how to install this helper program.
#
# Obviously, it helps to have an ssh agent running.
#
sub usage()
{
print(STDERR "ssh-mime.pl <control-file>\n");
}
my $optlist = "";
my $config;
# Locals
my $hostname;
my $gateway;
my $port = "";
my $login = "";
#
# Turn off line buffering on output
#
$| = 1;
#
# Parse command arguments. Once we return from getopts, all that should be
# left are the required arguments.
#
%options = ();
if (! getopts($optlist, \%options)) {
usage();
}
if (@ARGV != 1) {
usage();
}
$config = $ARGV[0];
#
# Open up the config file. It tells us what to do.
#
open(CONFIG, "< $config")
or die("Could not open config file $config: $!\n");
while (<CONFIG>) {
chomp();
SWITCH1: {
/^port:\s*(\d+)$/ && do {
$port = "-p $1";
last SWITCH1;
};
/^hostname:\s*([-\w\.]+)$/ && do {
$hostname = $1;
last SWITCH1;
};
/^gateway:\s*([-\w\.]+)$/ && do {
$gateway = $1;
last SWITCH1;
};
/^login:\s*([-\w]+)$/ && do {
$login = "-l $1";
last SWITCH1;
};
}
}
close(CONFIG);
#
# Must have a hostip. Port is optional.
#
if (!defined($hostname)) {
die("Config file must specify a hostname\n");
}
#
# Exec an ssh.
#
if (!defined($gateway)) {
exec "xterm -T $hostname -e ssh $port $login $hostname";
}
else {
exec "xterm -T $hostname -e ssh $login -tt $gateway ".
"ssh -o StrictHostKeyChecking=no $port $hostname";
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment