|
15 | 15 | import boto.exception |
16 | 16 | import time |
17 | 17 | import os |
18 | | -import paramiko |
19 | 18 | import socket |
20 | | -import interactive |
21 | 19 | import logging |
22 | 20 |
|
23 | 21 | import cfnconfig |
@@ -277,74 +275,3 @@ def delete(args): |
277 | 275 | print('\nExiting...') |
278 | 276 | sys.exit(0) |
279 | 277 |
|
280 | | -def sshmaster(args): |
281 | | - stack = ('cfncluster-' + args.cluster_name) |
282 | | - config = cfnconfig.CfnClusterConfig(args) |
283 | | - cfnconn = boto.cloudformation.connect_to_region(config.region,aws_access_key_id=config.aws_access_key_id, |
284 | | - aws_secret_access_key=config.aws_secret_access_key) |
285 | | - outputs = cfnconn.describe_stacks(stack)[0].outputs |
286 | | - if args.useprivateip: |
287 | | - hostname = [ o for o in outputs if o.key == 'MasterPrivateIP' ][0].value |
288 | | - else: |
289 | | - hostname = [ o for o in outputs if o.key == 'MasterPublicIP' ][0].value |
290 | | - port = 22 |
291 | | - |
292 | | - try: |
293 | | - sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) |
294 | | - sock.connect((hostname, port)) |
295 | | - except Exception, e: |
296 | | - print '*** Connect failed: ' + str(e) |
297 | | - traceback.print_exc() |
298 | | - sys.exit(1) |
299 | | - |
300 | | - try: |
301 | | - t = paramiko.Transport(sock) |
302 | | - try: |
303 | | - t.start_client() |
304 | | - except paramiko.SSHException: |
305 | | - print '*** SSH negotiation failed.' |
306 | | - sys.exit(1) |
307 | | - |
308 | | - try: |
309 | | - keys = paramiko.util.load_host_keys(os.path.expanduser('~/.ssh/known_hosts')) |
310 | | - except IOError: |
311 | | - try: |
312 | | - keys = paramiko.util.load_host_keys(os.path.expanduser('~/ssh/known_hosts')) |
313 | | - except IOError: |
314 | | - print '*** Unable to open host keys file' |
315 | | - keys = {} |
316 | | - |
317 | | - # check server's host key -- this is important. |
318 | | - key = t.get_remote_server_key() |
319 | | - if not keys.has_key(hostname): |
320 | | - print '*** WARNING: Unknown host key!' |
321 | | - elif not keys[hostname].has_key(key.get_name()): |
322 | | - print '*** WARNING: Unknown host key!' |
323 | | - elif keys[hostname][key.get_name()] != key: |
324 | | - print '*** WARNING: Host key has changed!!!' |
325 | | - sys.exit(1) |
326 | | - else: |
327 | | - print '*** Host key OK.' |
328 | | - |
329 | | - key = paramiko.RSAKey.from_private_key_file(config.key_location) |
330 | | - username = 'ec2-user' |
331 | | - t.auth_publickey(username, key) |
332 | | - |
333 | | - chan = t.open_session() |
334 | | - chan.get_pty() |
335 | | - chan.invoke_shell() |
336 | | - print '*** Here we go!' |
337 | | - print |
338 | | - interactive.interactive_shell(chan) |
339 | | - chan.close() |
340 | | - t.close() |
341 | | - |
342 | | - except Exception, e: |
343 | | - print '*** Caught exception: ' + str(e.__class__) + ': ' + str(e) |
344 | | - ##traceback.print_exc() |
345 | | - try: |
346 | | - t.close() |
347 | | - except: |
348 | | - pass |
349 | | - sys.exit(1) |
350 | | - |
0 commit comments