aws-ssh-utils 0.1.0__tar.gz → 0.2.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- aws_ssh_utils-0.2.0/LICENSE +21 -0
- aws_ssh_utils-0.2.0/PKG-INFO +117 -0
- aws_ssh_utils-0.2.0/README.md +79 -0
- aws_ssh_utils-0.2.0/aws_ssh_utils/__init__.py +1 -0
- {aws_ssh_utils-0.1.0 → aws_ssh_utils-0.2.0}/aws_ssh_utils/emr_utils.py +0 -10
- {aws_ssh_utils-0.1.0 → aws_ssh_utils-0.2.0}/aws_ssh_utils/ssh.py +61 -13
- {aws_ssh_utils-0.1.0 → aws_ssh_utils-0.2.0}/pyproject.toml +1 -1
- aws_ssh_utils-0.1.0/PKG-INFO +0 -113
- aws_ssh_utils-0.1.0/README.md +0 -76
- aws_ssh_utils-0.1.0/aws_ssh_utils/__init__.py +0 -1
- {aws_ssh_utils-0.1.0 → aws_ssh_utils-0.2.0}/.gitignore +0 -0
- {aws_ssh_utils-0.1.0 → aws_ssh_utils-0.2.0}/aws_ssh_utils/interactive_ssh.py +0 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 mvanderlee
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: aws-ssh-utils
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: Easy AWS SSHing
|
|
5
|
+
Project-URL: Homepage, https://github.com/mvanderlee/aws-ssh-utils
|
|
6
|
+
Author-email: Michiel Vanderlee <jmt.vanderlee@gmail.com>
|
|
7
|
+
License-Expression: MIT
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Classifier: Intended Audience :: Developers
|
|
10
|
+
Classifier: Intended Audience :: Information Technology
|
|
11
|
+
Classifier: Intended Audience :: System Administrators
|
|
12
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
13
|
+
Classifier: Operating System :: OS Independent
|
|
14
|
+
Classifier: Programming Language :: Python
|
|
15
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
19
|
+
Classifier: Topic :: Software Development
|
|
20
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
21
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
22
|
+
Classifier: Typing :: Typed
|
|
23
|
+
Requires-Python: >=3.11
|
|
24
|
+
Requires-Dist: boto3
|
|
25
|
+
Requires-Dist: click
|
|
26
|
+
Requires-Dist: click-spinner
|
|
27
|
+
Requires-Dist: coloredlogs
|
|
28
|
+
Requires-Dist: environs
|
|
29
|
+
Requires-Dist: loguru
|
|
30
|
+
Requires-Dist: paramiko
|
|
31
|
+
Requires-Dist: questionary
|
|
32
|
+
Provides-Extra: dev
|
|
33
|
+
Requires-Dist: boto3-stubs[ec2,emr]; extra == 'dev'
|
|
34
|
+
Provides-Extra: publish
|
|
35
|
+
Requires-Dist: hatch>=1.7.0; extra == 'publish'
|
|
36
|
+
Provides-Extra: test
|
|
37
|
+
Description-Content-Type: text/markdown
|
|
38
|
+
|
|
39
|
+
# AWS SSH Utils
|
|
40
|
+
|
|
41
|
+
[](https://pypi.org/project/aws-ssh-utils/)
|
|
42
|
+
[](#)
|
|
43
|
+
[](https://pypi.org/project/aws-ssh-utils/)
|
|
44
|
+
|
|
45
|
+
```shell
|
|
46
|
+
pip install aws-ssh-utils
|
|
47
|
+
|
|
48
|
+
aws_ssh ec2
|
|
49
|
+
|
|
50
|
+
aws_ssh emr
|
|
51
|
+
|
|
52
|
+
aws_ssh emr-all
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
This allows you to interactively SSH to an EC2 instance, EMR instance, or all EMR instances with TMUX.
|
|
56
|
+
|
|
57
|
+
It utilizes [questionary](https://pypi.org/project/questionary/) to ask you which instance you want to connect to.
|
|
58
|
+
|
|
59
|
+
## EC2
|
|
60
|
+
|
|
61
|
+
Select an instance from an interactive list. You can filter the instances by name.
|
|
62
|
+
|
|
63
|
+
```shell
|
|
64
|
+
$ aws_auth ec2 --help
|
|
65
|
+
Usage: aws_ssh ec2 [OPTIONS]
|
|
66
|
+
|
|
67
|
+
Asks user which EC2 instance they want to connect to, then opens an
|
|
68
|
+
interactive SSH session to the instance
|
|
69
|
+
|
|
70
|
+
Options:
|
|
71
|
+
-p, --profile TEXT Which AWS profile to use
|
|
72
|
+
-r, --region TEXT Which AWS region to use
|
|
73
|
+
-u, --user TEXT Which user to connect as
|
|
74
|
+
--private / --public Connect to the instance's private or public IP
|
|
75
|
+
-k, --key-file TEXT Which key file to use to connect
|
|
76
|
+
--help Show this message and exit.
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## EMR
|
|
80
|
+
|
|
81
|
+
Select the EMR cluster, instance group, and instance to connect to.
|
|
82
|
+
|
|
83
|
+
```shell
|
|
84
|
+
$ aws_ssh emr --help
|
|
85
|
+
Usage: aws_ssh emr [OPTIONS]
|
|
86
|
+
|
|
87
|
+
Asks user which Cluster and EC2 instance they want to connect to, then opens an interactive SSH session to the instance
|
|
88
|
+
|
|
89
|
+
Options:
|
|
90
|
+
-p, --profile TEXT Which AWS profile to use
|
|
91
|
+
-r, --region TEXT Which AWS region to use
|
|
92
|
+
-u, --user TEXT Which user to connect as
|
|
93
|
+
--private / --public Connect to the instance's private or public IP
|
|
94
|
+
-k, --key-file TEXT Which key file to use to connect
|
|
95
|
+
--help Show this message and exit.
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## EMR All
|
|
99
|
+
|
|
100
|
+
Select the EMR cluster to connect to. Then creates a new TMUX session with a window per instance. Each window will have an SSH connection to that instance open.
|
|
101
|
+
|
|
102
|
+
```shell
|
|
103
|
+
$ aws_ssh emr-all --help
|
|
104
|
+
Usage: aws_ssh emr-all [OPTIONS]
|
|
105
|
+
|
|
106
|
+
Asks user which Cluster and EC2 instance they want to connect to, Then
|
|
107
|
+
prints a tmux cli statement that will open a new session with a window per
|
|
108
|
+
ec2 instance with ssh shell already opened.
|
|
109
|
+
|
|
110
|
+
Options:
|
|
111
|
+
-p, --profile TEXT Which AWS profile to use
|
|
112
|
+
-r, --region TEXT Which AWS region to use
|
|
113
|
+
-u, --user TEXT Which user to connect as
|
|
114
|
+
--private / --public Connect to the instance's private or public IP
|
|
115
|
+
-k, --key-file TEXT Which key file to use to connect
|
|
116
|
+
--help Show this message and exit.
|
|
117
|
+
```
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# AWS SSH Utils
|
|
2
|
+
|
|
3
|
+
[](https://pypi.org/project/aws-ssh-utils/)
|
|
4
|
+
[](#)
|
|
5
|
+
[](https://pypi.org/project/aws-ssh-utils/)
|
|
6
|
+
|
|
7
|
+
```shell
|
|
8
|
+
pip install aws-ssh-utils
|
|
9
|
+
|
|
10
|
+
aws_ssh ec2
|
|
11
|
+
|
|
12
|
+
aws_ssh emr
|
|
13
|
+
|
|
14
|
+
aws_ssh emr-all
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
This allows you to interactively SSH to an EC2 instance, EMR instance, or all EMR instances with TMUX.
|
|
18
|
+
|
|
19
|
+
It utilizes [questionary](https://pypi.org/project/questionary/) to ask you which instance you want to connect to.
|
|
20
|
+
|
|
21
|
+
## EC2
|
|
22
|
+
|
|
23
|
+
Select an instance from an interactive list. You can filter the instances by name.
|
|
24
|
+
|
|
25
|
+
```shell
|
|
26
|
+
$ aws_auth ec2 --help
|
|
27
|
+
Usage: aws_ssh ec2 [OPTIONS]
|
|
28
|
+
|
|
29
|
+
Asks user which EC2 instance they want to connect to, then opens an
|
|
30
|
+
interactive SSH session to the instance
|
|
31
|
+
|
|
32
|
+
Options:
|
|
33
|
+
-p, --profile TEXT Which AWS profile to use
|
|
34
|
+
-r, --region TEXT Which AWS region to use
|
|
35
|
+
-u, --user TEXT Which user to connect as
|
|
36
|
+
--private / --public Connect to the instance's private or public IP
|
|
37
|
+
-k, --key-file TEXT Which key file to use to connect
|
|
38
|
+
--help Show this message and exit.
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## EMR
|
|
42
|
+
|
|
43
|
+
Select the EMR cluster, instance group, and instance to connect to.
|
|
44
|
+
|
|
45
|
+
```shell
|
|
46
|
+
$ aws_ssh emr --help
|
|
47
|
+
Usage: aws_ssh emr [OPTIONS]
|
|
48
|
+
|
|
49
|
+
Asks user which Cluster and EC2 instance they want to connect to, then opens an interactive SSH session to the instance
|
|
50
|
+
|
|
51
|
+
Options:
|
|
52
|
+
-p, --profile TEXT Which AWS profile to use
|
|
53
|
+
-r, --region TEXT Which AWS region to use
|
|
54
|
+
-u, --user TEXT Which user to connect as
|
|
55
|
+
--private / --public Connect to the instance's private or public IP
|
|
56
|
+
-k, --key-file TEXT Which key file to use to connect
|
|
57
|
+
--help Show this message and exit.
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## EMR All
|
|
61
|
+
|
|
62
|
+
Select the EMR cluster to connect to. Then creates a new TMUX session with a window per instance. Each window will have an SSH connection to that instance open.
|
|
63
|
+
|
|
64
|
+
```shell
|
|
65
|
+
$ aws_ssh emr-all --help
|
|
66
|
+
Usage: aws_ssh emr-all [OPTIONS]
|
|
67
|
+
|
|
68
|
+
Asks user which Cluster and EC2 instance they want to connect to, Then
|
|
69
|
+
prints a tmux cli statement that will open a new session with a window per
|
|
70
|
+
ec2 instance with ssh shell already opened.
|
|
71
|
+
|
|
72
|
+
Options:
|
|
73
|
+
-p, --profile TEXT Which AWS profile to use
|
|
74
|
+
-r, --region TEXT Which AWS region to use
|
|
75
|
+
-u, --user TEXT Which user to connect as
|
|
76
|
+
--private / --public Connect to the instance's private or public IP
|
|
77
|
+
-k, --key-file TEXT Which key file to use to connect
|
|
78
|
+
--help Show this message and exit.
|
|
79
|
+
```
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.2.0"
|
|
@@ -161,13 +161,3 @@ def get_emr_instance_ips(
|
|
|
161
161
|
]
|
|
162
162
|
for k, v in get_emr_instances(emr, cluster_id).items()
|
|
163
163
|
}
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
def get_instance_key_name(
|
|
167
|
-
emr: "EMRClient",
|
|
168
|
-
cluster_id: str,
|
|
169
|
-
) -> str:
|
|
170
|
-
cluster = emr.describe_cluster(ClusterId=cluster_id)
|
|
171
|
-
|
|
172
|
-
key_name = cluster["Cluster"]["Ec2InstanceAttributes"]["Ec2KeyName"]
|
|
173
|
-
return key_name
|
|
@@ -1,14 +1,18 @@
|
|
|
1
|
+
import datetime as dt
|
|
1
2
|
import logging
|
|
2
3
|
import os
|
|
4
|
+
import subprocess
|
|
3
5
|
import sys
|
|
4
6
|
import textwrap
|
|
5
|
-
from dataclasses import dataclass
|
|
7
|
+
from dataclasses import dataclass, field
|
|
8
|
+
from hashlib import sha1
|
|
6
9
|
from typing import TYPE_CHECKING
|
|
7
10
|
|
|
8
11
|
import boto3
|
|
9
12
|
import click
|
|
10
13
|
import click_spinner
|
|
11
14
|
import paramiko
|
|
15
|
+
import paramiko.pkey
|
|
12
16
|
import questionary
|
|
13
17
|
from botocore.exceptions import ClientError
|
|
14
18
|
from environs import Env
|
|
@@ -17,7 +21,6 @@ from loguru import logger
|
|
|
17
21
|
from .emr_utils import (
|
|
18
22
|
IP,
|
|
19
23
|
get_emr_instance_ips,
|
|
20
|
-
get_instance_key_name,
|
|
21
24
|
prompt_for_emr_cluster,
|
|
22
25
|
prompt_for_emr_instance_group,
|
|
23
26
|
)
|
|
@@ -28,6 +31,7 @@ if TYPE_CHECKING:
|
|
|
28
31
|
from mypy_boto3_emr import EMRClient
|
|
29
32
|
|
|
30
33
|
Env().read_env() # Load .env file
|
|
34
|
+
OPKSSH_PROVIDER_TAG = 'opkssh_provider'
|
|
31
35
|
|
|
32
36
|
|
|
33
37
|
class ShellError(Exception):
|
|
@@ -248,13 +252,6 @@ def emr_ssh_all(
|
|
|
248
252
|
exit(1)
|
|
249
253
|
|
|
250
254
|
|
|
251
|
-
@cli.command('test')
|
|
252
|
-
def test(**kwargs):
|
|
253
|
-
tmux('new-session -d -s "test" -n "window 1" "echo hello && $SHELL -i"')
|
|
254
|
-
tmux('new-window -n "window 2" -t "test:" "echo hello && $SHELL -i"')
|
|
255
|
-
tmux('switch-client -t "test:window 1"')
|
|
256
|
-
|
|
257
|
-
|
|
258
255
|
@dataclass
|
|
259
256
|
class SSHShell:
|
|
260
257
|
hostname: str
|
|
@@ -262,6 +259,17 @@ class SSHShell:
|
|
|
262
259
|
key_filename: str
|
|
263
260
|
terminal_title: str = None
|
|
264
261
|
|
|
262
|
+
private_key: paramiko.PKey = field(init=False)
|
|
263
|
+
|
|
264
|
+
def __post_init__(self):
|
|
265
|
+
if not os.path.isfile(self.key_filename):
|
|
266
|
+
raise ValueError(f'File {self.key_filename} does not exist')
|
|
267
|
+
|
|
268
|
+
self.private_key = paramiko.PKey.from_path(self.key_filename)
|
|
269
|
+
public_key_path = f'{self.key_filename}.pub'
|
|
270
|
+
if os.path.isfile(public_key_path):
|
|
271
|
+
self.private_key.load_certificate(public_key_path)
|
|
272
|
+
|
|
265
273
|
def connect(self):
|
|
266
274
|
self._open()
|
|
267
275
|
self._launch()
|
|
@@ -278,7 +286,11 @@ class SSHShell:
|
|
|
278
286
|
ssh_client.load_host_keys(host_key_path)
|
|
279
287
|
ssh_client.set_missing_host_key_policy(ConfirmAddPolicy())
|
|
280
288
|
try:
|
|
281
|
-
ssh_client.connect(
|
|
289
|
+
ssh_client.connect(
|
|
290
|
+
hostname=self.hostname,
|
|
291
|
+
username=self.username,
|
|
292
|
+
pkey=self.private_key,
|
|
293
|
+
)
|
|
282
294
|
except paramiko.BadHostKeyException as e:
|
|
283
295
|
error_message = f'''
|
|
284
296
|
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
|
@@ -359,8 +371,18 @@ def get_ec2_ssh_options(
|
|
|
359
371
|
key_file: str = None
|
|
360
372
|
) -> tuple[str, str, str, str]:
|
|
361
373
|
instance = prompt_for_ec2_instance(b3s)
|
|
374
|
+
instance_tags = {
|
|
375
|
+
tag['Key'].lower(): tag['Value']
|
|
376
|
+
for tag in instance.tags
|
|
377
|
+
}
|
|
378
|
+
|
|
362
379
|
if key_file is None:
|
|
363
|
-
|
|
380
|
+
# Support https://github.com/openpubkey/opkssh via tags
|
|
381
|
+
if OPKSSH_PROVIDER_TAG in instance_tags:
|
|
382
|
+
key_file = get_opkssh_key_file(instance_tags[OPKSSH_PROVIDER_TAG])
|
|
383
|
+
|
|
384
|
+
else:
|
|
385
|
+
key_file = try_to_find_ssh_key_file(instance.key_name)
|
|
364
386
|
|
|
365
387
|
if user is None:
|
|
366
388
|
logger.info('No user specified, attempting to detect required user...')
|
|
@@ -406,8 +428,17 @@ def get_emr_ssh_key_file_for_cluster(
|
|
|
406
428
|
cluster_id: str,
|
|
407
429
|
) -> str:
|
|
408
430
|
with click_spinner.spinner():
|
|
409
|
-
|
|
410
|
-
|
|
431
|
+
cluster = emr.describe_cluster(ClusterId=cluster_id)
|
|
432
|
+
cluster_tags = {
|
|
433
|
+
tag['Key'].lower(): tag['Value']
|
|
434
|
+
for tag in cluster['Cluster']['Tags']
|
|
435
|
+
}
|
|
436
|
+
# Support https://github.com/openpubkey/opkssh via tags
|
|
437
|
+
if OPKSSH_PROVIDER_TAG in cluster_tags:
|
|
438
|
+
key_file = get_opkssh_key_file(cluster_tags[OPKSSH_PROVIDER_TAG])
|
|
439
|
+
else:
|
|
440
|
+
key_name = cluster["Cluster"]["Ec2InstanceAttributes"]["Ec2KeyName"]
|
|
441
|
+
key_file = try_to_find_ssh_key_file(key_name)
|
|
411
442
|
|
|
412
443
|
if key_file is None:
|
|
413
444
|
should_continue = questionary.confirm(f'Could not find the ssh key {key_name}, would you like to continue?').unsafe_ask()
|
|
@@ -472,6 +503,23 @@ def get_ec2_name(ec2_instance: "Instance") -> str:
|
|
|
472
503
|
return ec2_instance.instance_id
|
|
473
504
|
|
|
474
505
|
|
|
506
|
+
def get_opkssh_key_file(provider: str) -> str:
|
|
507
|
+
opkssh_key_file = os.path.join(os.path.expanduser('~/.ssh/'), f'opkssh_{sha1(provider.encode()).hexdigest()}')
|
|
508
|
+
|
|
509
|
+
if os.path.exists(opkssh_key_file) and os.path.getmtime(opkssh_key_file) > dt.datetime.now().timestamp() - 86400:
|
|
510
|
+
logger.info('Found existing opkssh key')
|
|
511
|
+
else:
|
|
512
|
+
logger.info('Detected opkssh, logging in')
|
|
513
|
+
cmd = f"opkssh login --provider '{provider}' -i '{opkssh_key_file}'"
|
|
514
|
+
process = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE)
|
|
515
|
+
process.wait()
|
|
516
|
+
if process.returncode != 0:
|
|
517
|
+
logger.error('Failed to authenticate using opkssh')
|
|
518
|
+
sys.exit(process.returncode)
|
|
519
|
+
|
|
520
|
+
return opkssh_key_file
|
|
521
|
+
|
|
522
|
+
|
|
475
523
|
class ConfirmAddPolicy(paramiko.client.MissingHostKeyPolicy):
|
|
476
524
|
"""
|
|
477
525
|
Policy for automatically adding the hostname and new host key to the
|
aws_ssh_utils-0.1.0/PKG-INFO
DELETED
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: aws-ssh-utils
|
|
3
|
-
Version: 0.1.0
|
|
4
|
-
Summary: Easy AWS SSHing
|
|
5
|
-
Project-URL: Homepage, https://github.com/mvanderlee/aws_ssh_utils
|
|
6
|
-
Author-email: Michiel Vanderlee <jmt.vanderlee@gmail.com>
|
|
7
|
-
License-Expression: MIT
|
|
8
|
-
Classifier: Intended Audience :: Developers
|
|
9
|
-
Classifier: Intended Audience :: Information Technology
|
|
10
|
-
Classifier: Intended Audience :: System Administrators
|
|
11
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
12
|
-
Classifier: Operating System :: OS Independent
|
|
13
|
-
Classifier: Programming Language :: Python
|
|
14
|
-
Classifier: Programming Language :: Python :: 3 :: Only
|
|
15
|
-
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
-
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
-
Classifier: Programming Language :: Python :: 3.13
|
|
18
|
-
Classifier: Topic :: Software Development
|
|
19
|
-
Classifier: Topic :: Software Development :: Libraries
|
|
20
|
-
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
21
|
-
Classifier: Typing :: Typed
|
|
22
|
-
Requires-Python: >=3.11
|
|
23
|
-
Requires-Dist: boto3
|
|
24
|
-
Requires-Dist: click
|
|
25
|
-
Requires-Dist: click-spinner
|
|
26
|
-
Requires-Dist: coloredlogs
|
|
27
|
-
Requires-Dist: environs
|
|
28
|
-
Requires-Dist: loguru
|
|
29
|
-
Requires-Dist: paramiko
|
|
30
|
-
Requires-Dist: questionary
|
|
31
|
-
Provides-Extra: dev
|
|
32
|
-
Requires-Dist: boto3-stubs[ec2,emr]; extra == 'dev'
|
|
33
|
-
Provides-Extra: publish
|
|
34
|
-
Requires-Dist: hatch>=1.7.0; extra == 'publish'
|
|
35
|
-
Provides-Extra: test
|
|
36
|
-
Description-Content-Type: text/markdown
|
|
37
|
-
|
|
38
|
-
# AWS Auth
|
|
39
|
-
|
|
40
|
-
```shell
|
|
41
|
-
pip install aws-auth-utils
|
|
42
|
-
|
|
43
|
-
aws configure --profile mfa-source
|
|
44
|
-
|
|
45
|
-
aws_auth mfa
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
The commands use [click](https://click.palletsprojects.com/en/stable/) for argument parsing and if required arguments are missing it will prompt you.
|
|
49
|
-
|
|
50
|
-
To authenticate using your MFA token you will need to have a profile configured using regular an AWS Access Key.
|
|
51
|
-
|
|
52
|
-
We will use that and your MFA token to generate an authorized session profile.
|
|
53
|
-
By default we will try to use the `mfa-source` and create the `default` profile.
|
|
54
|
-
|
|
55
|
-
If you only have a single MFA device set up, it will use that automatically. If you have multiple, it will the first one.
|
|
56
|
-
|
|
57
|
-
## MFA
|
|
58
|
-
|
|
59
|
-
```shell
|
|
60
|
-
$ aws_auth mfa --help
|
|
61
|
-
Usage: aws_auth mfa [OPTIONS]
|
|
62
|
-
|
|
63
|
-
Options:
|
|
64
|
-
-a, --mfa-arn TEXT The identification number of the MFA device that
|
|
65
|
-
is associated with the IAM user. i.e.:
|
|
66
|
-
"arn:aws:iam::123456789012:mfa/tony.stark". You
|
|
67
|
-
can find this on the IAM page.
|
|
68
|
-
-c, --code TEXT The code generated by your MFA device.
|
|
69
|
-
-d, --duration INTEGER The duration, in seconds, of the session.
|
|
70
|
-
-sp, --source-profile TEXT What AWS profile to get the session token with.
|
|
71
|
-
-tp, --target-profile TEXT What AWS profile to store the credentials under.
|
|
72
|
-
-v, --verbose BOOLEAN
|
|
73
|
-
--help Show this message and exit.
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
## Assume Role
|
|
77
|
-
|
|
78
|
-
The assume role is useful for multi-org environments where you want to impersonate a role in a child organization.
|
|
79
|
-
If you access multiple organizations I recommend you set up aliases.
|
|
80
|
-
|
|
81
|
-
```shell
|
|
82
|
-
aws_auth assume \
|
|
83
|
-
--role-arn arn:aws:iam::123456789012:role/OrganizationAccountAccessRole \
|
|
84
|
-
--session-name child_org \
|
|
85
|
-
--target-profile child_session
|
|
86
|
-
```
|
|
87
|
-
|
|
88
|
-
```shell
|
|
89
|
-
$ aws_auth assume --help
|
|
90
|
-
Usage: aws_auth assume [OPTIONS]
|
|
91
|
-
|
|
92
|
-
Get MFA authenticated and assumed role session credentials and save them to
|
|
93
|
-
the aws credentials file
|
|
94
|
-
|
|
95
|
-
If you have multiple accounts you'd like to switch between, I recommend
|
|
96
|
-
setting up aliases that call this script with predefined arguments.
|
|
97
|
-
|
|
98
|
-
Options:
|
|
99
|
-
-r, --role-arn TEXT The Arn of the Role to assume.
|
|
100
|
-
-n, --session-name TEXT The identifier for the assumed role session.
|
|
101
|
-
-a, --mfa-arn TEXT The identification number of the MFA device that
|
|
102
|
-
is associated with the IAM user. i.e.:
|
|
103
|
-
"arn:aws:iam::123456789012:mfa/tony.stark". You
|
|
104
|
-
can find this on the IAM page.
|
|
105
|
-
-c, --code TEXT The code generated by your MFA device.
|
|
106
|
-
-d, --duration INTEGER The duration, in seconds, of the session.
|
|
107
|
-
(defaults to 4 hours)
|
|
108
|
-
-sp, --source-profile TEXT What AWS profile to get the session token with.
|
|
109
|
-
-tp, --target-profile TEXT What AWS profile to store the credentials under.
|
|
110
|
-
-v, --verbose BOOLEAN
|
|
111
|
-
--help Show this message and exit.
|
|
112
|
-
```
|
|
113
|
-
|
aws_ssh_utils-0.1.0/README.md
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
# AWS Auth
|
|
2
|
-
|
|
3
|
-
```shell
|
|
4
|
-
pip install aws-auth-utils
|
|
5
|
-
|
|
6
|
-
aws configure --profile mfa-source
|
|
7
|
-
|
|
8
|
-
aws_auth mfa
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
The commands use [click](https://click.palletsprojects.com/en/stable/) for argument parsing and if required arguments are missing it will prompt you.
|
|
12
|
-
|
|
13
|
-
To authenticate using your MFA token you will need to have a profile configured using regular an AWS Access Key.
|
|
14
|
-
|
|
15
|
-
We will use that and your MFA token to generate an authorized session profile.
|
|
16
|
-
By default we will try to use the `mfa-source` and create the `default` profile.
|
|
17
|
-
|
|
18
|
-
If you only have a single MFA device set up, it will use that automatically. If you have multiple, it will the first one.
|
|
19
|
-
|
|
20
|
-
## MFA
|
|
21
|
-
|
|
22
|
-
```shell
|
|
23
|
-
$ aws_auth mfa --help
|
|
24
|
-
Usage: aws_auth mfa [OPTIONS]
|
|
25
|
-
|
|
26
|
-
Options:
|
|
27
|
-
-a, --mfa-arn TEXT The identification number of the MFA device that
|
|
28
|
-
is associated with the IAM user. i.e.:
|
|
29
|
-
"arn:aws:iam::123456789012:mfa/tony.stark". You
|
|
30
|
-
can find this on the IAM page.
|
|
31
|
-
-c, --code TEXT The code generated by your MFA device.
|
|
32
|
-
-d, --duration INTEGER The duration, in seconds, of the session.
|
|
33
|
-
-sp, --source-profile TEXT What AWS profile to get the session token with.
|
|
34
|
-
-tp, --target-profile TEXT What AWS profile to store the credentials under.
|
|
35
|
-
-v, --verbose BOOLEAN
|
|
36
|
-
--help Show this message and exit.
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
## Assume Role
|
|
40
|
-
|
|
41
|
-
The assume role is useful for multi-org environments where you want to impersonate a role in a child organization.
|
|
42
|
-
If you access multiple organizations I recommend you set up aliases.
|
|
43
|
-
|
|
44
|
-
```shell
|
|
45
|
-
aws_auth assume \
|
|
46
|
-
--role-arn arn:aws:iam::123456789012:role/OrganizationAccountAccessRole \
|
|
47
|
-
--session-name child_org \
|
|
48
|
-
--target-profile child_session
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
```shell
|
|
52
|
-
$ aws_auth assume --help
|
|
53
|
-
Usage: aws_auth assume [OPTIONS]
|
|
54
|
-
|
|
55
|
-
Get MFA authenticated and assumed role session credentials and save them to
|
|
56
|
-
the aws credentials file
|
|
57
|
-
|
|
58
|
-
If you have multiple accounts you'd like to switch between, I recommend
|
|
59
|
-
setting up aliases that call this script with predefined arguments.
|
|
60
|
-
|
|
61
|
-
Options:
|
|
62
|
-
-r, --role-arn TEXT The Arn of the Role to assume.
|
|
63
|
-
-n, --session-name TEXT The identifier for the assumed role session.
|
|
64
|
-
-a, --mfa-arn TEXT The identification number of the MFA device that
|
|
65
|
-
is associated with the IAM user. i.e.:
|
|
66
|
-
"arn:aws:iam::123456789012:mfa/tony.stark". You
|
|
67
|
-
can find this on the IAM page.
|
|
68
|
-
-c, --code TEXT The code generated by your MFA device.
|
|
69
|
-
-d, --duration INTEGER The duration, in seconds, of the session.
|
|
70
|
-
(defaults to 4 hours)
|
|
71
|
-
-sp, --source-profile TEXT What AWS profile to get the session token with.
|
|
72
|
-
-tp, --target-profile TEXT What AWS profile to store the credentials under.
|
|
73
|
-
-v, --verbose BOOLEAN
|
|
74
|
-
--help Show this message and exit.
|
|
75
|
-
```
|
|
76
|
-
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.1.0"
|
|
File without changes
|
|
File without changes
|