Et bien sûr on peut parfaitement l'utiliser sous Jython :-)
Voici un exemple de servlet Jython utlisant Ganymed.
http://www.ganymed.ethz.ch/ssh2/
from javax.servlet.http import HttpServlet
from ch.ethz.ssh2 import Connection,Session,StreamGobbler
from java.io import BufferedReader, InputStreamReader
hostname = '127.0.0.1'
username = 'admin'
password = 'Yu8KL%'
class MonServeur (HttpServlet):
def doGet(self,request,response):
self.doPost (request,response)
def doPost(self,request,response):
sortie = []
conn = Connection(hostname)
conn.connect()
isConnected = conn.authenticateWithPassword(username, password);
sess = conn.openSession()
sess.execCommand("uname -a && df -k")
stdout = StreamGobbler(sess.getStdout())
inputStreamReader = InputStreamReader(stdout)
br = BufferedReader(inputStreamReader)
toClient = response.getWriter()
response.setContentType ("text/html")
while (1):
line = br.readLine()
if line == None:
break
sortie.append(line)
toClient.println (sortie)