Skip to content
Permalink
Browse files

Added `-6` option to ssh into slaac address

  • Loading branch information...
Dorthu committed Apr 29, 2019
1 parent 82abf8b commit 0044747fa4f7c665025ff6f6146e019ebf0ee0d7
Showing with 11 additions and 6 deletions.
  1. +11 −6 linodecli/plugins/ssh.py
@@ -40,6 +40,8 @@ def call(args, context):
help="The label of the Linode to SSH into, optionally with "
"a username before it in USERNAME@LABEL format. If no "
"username is given, defaults to the current user.")
parser.add_argument('-6', action='store_true',
help="If given, uses the Linode's SLAAC address for SSH.")

parsed, args = parser.parse_known_args(args)

@@ -56,8 +58,7 @@ def call(args, context):
"linodes", "list", filters={'label': {"+contains": label}})

if result != 200:
# TODO
print('Something went wrong')
print('Could not retrieve Linode: {} error'.format(result))
exit(2)

potential_matches = potential_matches['data']
@@ -85,10 +86,14 @@ def call(args, context):

# find a public IP Address to use
public_ip = None
for ip in exact_match['ipv4']:
if not ip.startswith('192.168'):
public_ip = ip # TODO - this uses the "first" IP Address
break

if getattr(parsed, '6'): # this is necessary since the name isn't a valid python variable name
public_ip = exact_match['ipv6'].split('/')[0]
else:
for ip in exact_match['ipv4']:
if not ip.startswith('192.168'):
public_ip = ip # TODO - this uses the "first" IP Address
break

address = public_ip
if username:

0 comments on commit 0044747

Please sign in to comment.
You can’t perform that action at this time.