Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
configuration
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
configuration
Commits
006dee6b
Commit
006dee6b
authored
Mar 04, 2014
by
John Jarvis
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #844 from edx/jarv/bastion-ssh-config
create alias for bastion
parents
f064db8f
bb69502a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
74 additions
and
44 deletions
+74
-44
util/vpc-tools/vpc-tools.py
+74
-44
No files found.
util/vpc-tools/vpc-tools.py
View file @
006dee6b
...
...
@@ -21,27 +21,35 @@ VERSION="vpc tools 0.1"
DEFAULT_USER
=
"ubuntu"
DEFAULT_HOST_CHECK
=
"ask"
JUMPBOX_CONFIG
=
"""
Host {jump_box}
HostName {ip}
ForwardAgent yes
User {user}
StrictHostKeyChecking {strict_host_check}
{identity_line}
BASTION_CONFIG
=
"""Host {jump_box}
HostName {ip}
ForwardAgent yes
User {user}
StrictHostKeyChecking {strict_host_check}
{identity_line}
"""
HOST_CONFIG
=
"""
# Instance ID: {instance_id}
Host {name}
ProxyCommand ssh {config_file} -W
%
h:
%
p {jump_box}
HostName {ip}
ForwardAgent yes
User {user}
StrictHostKeyChecking {strict_host_check}
{identity_line}
HOST_CONFIG
=
"""# Instance ID: {instance_id}
Host {name}
ProxyCommand ssh {config_file} -W
%
h:
%
p {jump_box}
HostName {ip}
ForwardAgent yes
User {user}
StrictHostKeyChecking {strict_host_check}
{identity_line}
"""
BASTION_HOST_CONFIG
=
"""# Instance ID: {instance_id}
Host {name}
HostName {ip}
ForwardAgent yes
User {user}
StrictHostKeyChecking {strict_host_check}
{identity_line}
"""
def
dispatch
(
args
):
if
args
.
get
(
"ssh-config"
):
...
...
@@ -80,7 +88,7 @@ def _ssh_config(args):
else
:
config_file
=
""
jump_box
=
"{stack_name}-
jumpbox
"
.
format
(
stack_name
=
stack_name
)
jump_box
=
"{stack_name}-
bastion
"
.
format
(
stack_name
=
stack_name
)
friendly
=
"{stack_name}-{logical_id}-{instance_number}"
id_type_counter
=
defaultdict
(
int
)
...
...
@@ -105,39 +113,61 @@ def _ssh_config(args):
if
logical_id
==
"BastionHost"
or
logical_id
==
'bastion'
:
print
JUMPBOX
_CONFIG
.
format
(
print
BASTION
_CONFIG
.
format
(
jump_box
=
jump_box
,
ip
=
instance
.
ip_address
,
user
=
user
,
strict_host_check
=
strict_host_check
,
identity_line
=
identity_line
)
# Print host config even for the bastion box because that is how
# ansible accesses it.
print
HOST_CONFIG
.
format
(
name
=
instance
.
private_ip_address
,
jump_box
=
jump_box
,
ip
=
instance
.
private_ip_address
,
user
=
user
,
config_file
=
config_file
,
strict_host_check
=
strict_host_check
,
instance_id
=
instance
.
id
,
identity_line
=
identity_line
)
#duplicating for convenience with ansible
name
=
friendly
.
format
(
stack_name
=
stack_name
,
logical_id
=
logical_id
,
instance_number
=
instance_number
)
print
HOST_CONFIG
.
format
(
name
=
name
,
jump_box
=
jump_box
,
ip
=
instance
.
private_ip_address
,
user
=
user
,
config_file
=
config_file
,
strict_host_check
=
strict_host_check
,
instance_id
=
instance
.
id
,
identity_line
=
identity_line
)
print
BASTION_HOST_CONFIG
.
format
(
name
=
instance
.
private_ip_address
,
ip
=
instance
.
ip_address
,
user
=
user
,
instance_id
=
instance
.
id
,
strict_host_check
=
strict_host_check
,
identity_line
=
identity_line
)
#duplicating for convenience with ansible
name
=
friendly
.
format
(
stack_name
=
stack_name
,
logical_id
=
logical_id
,
instance_number
=
instance_number
)
print
BASTION_HOST_CONFIG
.
format
(
name
=
name
,
ip
=
instance
.
ip_address
,
user
=
user
,
strict_host_check
=
strict_host_check
,
instance_id
=
instance
.
id
,
identity_line
=
identity_line
)
else
:
# Print host config even for the bastion box because that is how
# ansible accesses it.
print
HOST_CONFIG
.
format
(
name
=
instance
.
private_ip_address
,
jump_box
=
jump_box
,
ip
=
instance
.
private_ip_address
,
user
=
user
,
config_file
=
config_file
,
strict_host_check
=
strict_host_check
,
instance_id
=
instance
.
id
,
identity_line
=
identity_line
)
#duplicating for convenience with ansible
name
=
friendly
.
format
(
stack_name
=
stack_name
,
logical_id
=
logical_id
,
instance_number
=
instance_number
)
print
HOST_CONFIG
.
format
(
name
=
name
,
jump_box
=
jump_box
,
ip
=
instance
.
private_ip_address
,
user
=
user
,
config_file
=
config_file
,
strict_host_check
=
strict_host_check
,
instance_id
=
instance
.
id
,
identity_line
=
identity_line
)
if
__name__
==
'__main__'
:
args
=
docopt
(
__doc__
,
version
=
VERSION
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment