-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GITBOOK-644: change request with no subject merged in GitBook
- Loading branch information
1 parent
162f55a
commit 5898b2a
Showing
3 changed files
with
107 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
# EC2 | ||
|
||
|
||
|
||
## Connect to instance | ||
|
||
### Direct SSH or RDP | ||
|
||
Use a standard SSH or RDP connection to reach the instance. | ||
|
||
* Requires knowing the Elastic or Private IP of the machine | ||
* The Security Group associated with the instance must allow inbound SSH or RDP connections | ||
* The SSH or RDP service must be configured and running on the machine | ||
* Since the authentication procedure is managed directly on the instance, no AWS credentials or keys are needed | ||
|
||
### EC2 Connect | ||
|
||
A browser based shell leveraging temporary SSH keys as backed against IAM credentials. Can be accessed from the AWS dashboard or from the url below | ||
|
||
* Requires configuration of an agent on the target machine | ||
* In order to use this access method from a remote SSH Client, the SSH port must be reachable from the internet and the user must own valid IAM credentials | ||
|
||
Direct URL: | ||
|
||
``` | ||
https:/<region>.console.aws.amazon.com/ec2-instance-connect/ssh?region=<region>&connType=standard&instanceId=<instance id>osUser=<ec2 user>&sshPort=22#/ | ||
``` | ||
|
||
### AWS SSM | ||
|
||
AWS Simple System Management allows to install a package or run a command on a Linux or Windows server. This service can also be used to obtain a shell on the EC2 instance using the AWS Systems Manager Session Manager service. | ||
|
||
* Requires configuration of an agent on the target machine | ||
* The EC2 instance must own the correct IAM permissions to enable this service | ||
* The user must own valid IAM user credentials to use this service | ||
* Does not require direct network access to the instance | ||
|
||
### **EC2 Serial Console** | ||
|
||
This method of authentication allows a user to authenticate on the EC2 instance only by knowing the host's username and password. | ||
|
||
* An administrator must enable the EC2 Serial Console for the whole region | ||
* Users on the instance must have a password defined, otherwise it will be impossible to login as them | ||
* Does not require valid IAM User credentials | ||
* Does not require direct network access to the EC2 instance | ||
|
||
## IMDS | ||
|
||
### Get instance information | ||
|
||
Get current role | ||
|
||
``` | ||
curl -s http://169.254.169.254/latest/meta-data/iam/security-credentials/ | ||
``` | ||
|
||
Get instance ID | ||
|
||
``` | ||
curl -s http://169.254.169.254/latest/meta-data/instance-id | ||
``` | ||
|
||
Get instance region | ||
|
||
``` | ||
curl -s http://169.254.169.254/latest/meta-data/placement/region | ||
``` | ||
|
||
### Enable IMDSv2 | ||
|
||
Enable IMDv2 for current instance | ||
|
||
``` | ||
aws ec2 modify-instance-metadata-options --instance-id <instance id> --http-tokens required --region <region> | ||
``` | ||
|
||
One line command with required calls included | ||
|
||
``` | ||
aws ec2 modify-instance-metadata-options --instance-id $(curl -s http://169.254.169.254/latest/meta-data/instance-id) --http-tokens required --region $(curl -s http://169.254.169.254/latest/meta-data/placement/region) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters