Skip to content

Commit 438ea19

Browse files
authored
connect to bastion through ssh docs (#9)
* connect to bastion through ssh docs * fix changes * disable markdown rule * disable MD051
1 parent a6f44be commit 438ea19

File tree

2 files changed

+35
-6
lines changed

2 files changed

+35
-6
lines changed

.markdownlint.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@
66
"MD033": false,
77
"MD024": false,
88
"MD029": false,
9-
"MD053": false
9+
"MD053": false,
10+
"MD051": false
1011
}

live/core/README.md

+33-5
Original file line numberDiff line numberDiff line change
@@ -94,14 +94,42 @@ echo "VPC ID: $vpc_id"
9494
9595
### Connecting to the Bastion Host
9696
97-
To establish a connection with the bastion host, use the following commands:
97+
To establish a secure connection with the bastion host, follow these steps:
98+
99+
#### Obtain Required Information
100+
101+
First, you need to gather some essential information:
102+
103+
- Bastion SSH Parameter Name
104+
- Bastion Instance ID
105+
106+
You can retrieve these values using Terraform:
98107
99108
```bash
100-
# Retrieve the SSH command from the Terraform output
101-
ssh_command=$(terraform output -json | jq -r '.bastion_ssh_command.value')
109+
bastion_ssh_parameter_name=$(terraform output -json | jq -r '.ssm_parameter_bastion_ssh_key.value')
110+
bastion_instance_id=$(terraform output -json | jq -r '.bastion_instance_id.value')
111+
```
112+
113+
#### Generate .pem file with the ssh key
114+
115+
```bash
116+
aws ssm get-parameter --name "$bastion_ssh_parameter_name" --with-decryption --query 'Parameter.Value' --output text > /tmp/ssh_key.pem
117+
chmod 400 /tmp/ssh_key.pem
118+
```
102119
103-
# Execute the SSH command
104-
eval $ssh_command
120+
#### Retrieve bastion's public IP
121+
122+
```bash
123+
bastion_public_ip=$(aws ec2 describe-instances --instance-ids "$bastion_instance_id" --query 'Reservations[0].Instances[0].PublicIpAddress' --output text | tr '.' '-')
124+
125+
# Print the value
126+
echo "Bastion IP: $bastion_public_ip"
127+
```
128+
129+
#### Connect to Bastion Host
130+
131+
```bash
132+
ssh -i "/tmp/ssh_key.pem" ubuntu@ec2-"$bastion_public_ip".us-west-2.compute.amazonaws.com
105133
```
106134
107135
Ensure that you can access the database from the bastion host and verify that Docker is functioning correctly.

0 commit comments

Comments
 (0)