forked from donbowman/openstack-proxy
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathssh-jump
More file actions
executable file
·43 lines (32 loc) · 1.17 KB
/
ssh-jump
File metadata and controls
executable file
·43 lines (32 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/python
"""
ssh-jump: 'netcat' that finds a nova instance, and jumps
into its namespace.
"""
import traceback, sys
import os, sys
import prctl
import shlex
import find_ns
from datetime import datetime
if (len(sys.argv) == 1):
sys.argv.extend(shlex.split(sys.stdin.readline()))
args = find_ns.do_args()
try:
# This allows our app to get into a network namespace other than the default.
# to do so, open /var/run/netns/<file>, and then have @ it with the fd using
# the setns(2) call. E.g. f=open('/var/run/netns/x'); setns(f)
prctl.cap_permitted.sys_admin = True
prctl.cap_effective.sys_admin = True
h, ns,floating = find_ns.find_host(args.user, args.tenant, args.password, args.host, args.auth_url)
if (len(ns)):
_ns = find_ns.NS(ns)
os.execv('/bin/nc',['/bin/nc', h, '22'])
except:
dt = datetime.now()
print("TIMESTAMP: %s" % dt.isoformat("T"))
traceback.print_exc()
print("Usage: -user <USER> -password <PASSWORD> -tenant <TENANT> -host <HOST>")
print("where USER/PASSWORD/TENANT/HOST are all as per this OpenStack deployment")
print("and may not be a Unix login")
print("You gave: <<%s>>" % sys.argv)