From 0a1ae9c4be5be474790073cbdc577f5f092510ab Mon Sep 17 00:00:00 2001 From: Sven Slootweg Date: Tue, 8 May 2012 02:46:06 +0200 Subject: [PATCH] Add first version of dropper script --- console/master/dropper.py | 50 +++++++++++++++++++++++++++++++++++++++ frontend/index.php | 16 +++++++++++++ 2 files changed, 66 insertions(+) create mode 100644 console/master/dropper.py create mode 100644 frontend/index.php diff --git a/console/master/dropper.py b/console/master/dropper.py new file mode 100644 index 0000000..0ddae6b --- /dev/null +++ b/console/master/dropper.py @@ -0,0 +1,50 @@ +#!/usr/bin/env python + +import paramiko, socket, sys, termios, tty, select + + +def posix_shell(chan): + oldtty = termios.tcgetattr(sys.stdin) + + try: + tty.setraw(sys.stdin.fileno()) + tty.setcbreak(sys.stdin.fileno()) + chan.settimeout(0.0) + + while True: + r, w, e = select.select([chan, sys.stdin], [], []) + if chan in r: + try: + buff = chan.recv(1024) + if len(buff) == 0: + print '\r\nYou have been logged out of your container.\r\n', + break + sys.stdout.write(buff) + sys.stdout.flush() + except socket.timeout: + pass + if sys.stdin in r: + buff = sys.stdin.read(1) + if len(buff) == 0: + break + chan.send(buff) + + finally: + termios.tcsetattr(sys.stdin, termios.TCSADRAIN, oldtty) + + + + + +ssh = paramiko.SSHClient() +ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) + +sshkey = paramiko.RSAKey.from_private_key_file('/etc/cvm/key') + +ssh.connect('cvm-vz.cryto.net', username='root', pkey=sshkey) + +chan = ssh.invoke_shell() +posix_shell(chan) + +chan.close() +ssh.close() diff --git a/frontend/index.php b/frontend/index.php new file mode 100644 index 0000000..08660b9 --- /dev/null +++ b/frontend/index.php @@ -0,0 +1,16 @@ +