Skip to content

Commit 3fcbe31

Browse files
Added Postfix and Proxy for Multiple Bastion's and Accounts
Original commit from Ermis Catevatis (https://github.com/ErmisCat)
1 parent e3259ac commit 3fcbe31

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

aws-ssh-config.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ def main():
6565
parser.add_argument('--prefix', default='', help='Specify a prefix to prepend to all host names')
6666
parser.add_argument('--private', action='store_true', help='Use private IP addresses (public are used by default)')
6767
parser.add_argument('--profile', help='Specify AWS credential profile to use')
68+
parser.add_argument('--postfix', default='', help='Specify a postfix to append to all host names')
69+
parser.add_argument('--proxy', default='', help='Specify a bastion host for ProxyCommand')
6870
parser.add_argument('--region', action='store_true', help='Append the region name at the end of the concatenation')
6971
parser.add_argument('--ssh-key-name', default='', help='Override the ssh key to use')
7072
parser.add_argument('--strict-hostkey-checking', action='store_true', help='Do not include StrictHostKeyChecking=no in ssh config')
@@ -155,7 +157,7 @@ def main():
155157
counts_incremental[instance_id] += 1
156158
instance_id += '-' + str(counts_incremental[instance_id])
157159

158-
hostid = args.prefix + instance_id
160+
hostid = args.prefix + instance_id + args.postfix
159161
hostid = hostid.replace(' ', '_') # get rid of spaces
160162

161163
if instance.id:
@@ -186,6 +188,8 @@ def main():
186188
print(' IdentitiesOnly yes')
187189
if not args.strict_hostkey_checking:
188190
print(' StrictHostKeyChecking no')
191+
if args.proxy:
192+
print(' ProxyCommand ssh ' + args.proxy + ' -W %h:%p')
189193
print('')
190194

191195

0 commit comments

Comments
 (0)