From 55b7f22404da7a0cfcdbce467e9581f6b8509320 Mon Sep 17 00:00:00 2001 From: Kenny Woodson Date: Thu, 5 Feb 2015 14:18:09 -0500 Subject: Updated tab completion as well as respecting ssh config files. --- bin/ossh | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'bin/ossh') diff --git a/bin/ossh b/bin/ossh index 1cef1b4fa..7f7acc6c2 100755 --- a/bin/ossh +++ b/bin/ossh @@ -84,6 +84,7 @@ class Ossh(object): '''Determine host name and user name for SSH. ''' self.env = None + self.user = None re_env = re.compile('\.(int|stg|prod|ops)') search = re_env.search(self.args.host) @@ -104,10 +105,6 @@ class Ossh(object): self.host = self.args.host if self.args.login_name: self.user = self.args.login_name - else: - self.user = os.environ['USER'] - - def get_hosts(self): '''Query our host inventory and return a dict where the format @@ -192,8 +189,12 @@ class Ossh(object): ''' try: cmd = '/usr/bin/ssh' - ssh_args = [cmd, '-l%s' % self.user] - #ssh_args = [cmd, ] + + # shell args start with the program name in position 1 + ssh_args = [cmd, ] + + if self.user: + ssh_args.append('-l%s' % self.user) if self.args.verbose: ssh_args.append('-vvv') @@ -211,9 +212,9 @@ class Ossh(object): # Assume we have one and only one. hostname, server_info = result[0] - ip = server_info['ec2_ip_address'] + dns = server_info['ec2_public_dns_name'] - ssh_args.append(ip) + ssh_args.append(dns) #last argument if self.args.command: -- cgit v1.2.3