Skip to content

Commit d01d5f5

Browse files
committed
docs: add credentials management docs and update code
1 parent 24e205f commit d01d5f5

File tree

3 files changed

+87
-1
lines changed

3 files changed

+87
-1
lines changed

.env.example

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
MACHINE_IP=45.55.184.5
2+
MACHINE_USER=root
3+
SSH_PRIVATE_KEY_PATH=./credentials/ansible_hub_key

.gitignore

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# Ansible
2+
*.retry
3+
*.pyc
4+
__pycache__/
5+
16
# Ignore Ansible Vault files
27
*.vault
38

@@ -8,10 +13,31 @@
813
# Ignore other common files
914
*.swp
1015
*.swo
16+
17+
18+
# OS generated files
1119
.DS_Store
20+
.DS_Store?
21+
._*
22+
.Spotlight-V100
23+
.Trashes
24+
ehthumbs.db
1225
Thumbs.db
1326

27+
# Environment variables
1428
.env
1529

30+
# Credentials
1631
credentials/*
1732
!credentials/README.md
33+
34+
# IDE specific files
35+
.idea/
36+
.vscode/
37+
*.swp
38+
*.swo
39+
*~
40+
41+
# Temporary files
42+
*.tmp
43+
*.bak

credentials/README.md

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,65 @@
1+
# SSH Key Management for Ansible
2+
3+
This guide explains how to set up and manage SSH keys for Ansible automation.
4+
5+
## Generate SSH Key
6+
7+
Run these commands from the project root:
8+
19
```bash
210
cd credentials
311
ssh-keygen -t rsa -b 2048 -f "$(pwd)/ansible_hub_key"
412
```
513

14+
This will create:
15+
- `ansible_hub_key` (private key)
16+
- `ansible_hub_key.pub` (public key)
17+
18+
## Key Usage
19+
20+
### Test SSH Connection
621
```bash
7-
ssh -i ./ansible_hub_key root@167.172.25.133
22+
ssh -i ./ansible_hub_key root@your-server-ip
823
```
24+
25+
### Setup Steps
26+
27+
1. Copy the public key to your target server:
28+
```bash
29+
ssh-copy-id -i ./ansible_hub_key.pub root@your-server-ip
30+
```
31+
32+
2. Set proper permissions:
33+
```bash
34+
chmod 600 ansible_hub_key
35+
```
36+
37+
3. Update your `.env` file with the correct path:
38+
```
39+
SSH_PRIVATE_KEY_PATH=./credentials/ansible_hub_key
40+
```
41+
42+
43+
## Using AWS PEM Key
44+
45+
If you're using an AWS EC2 instance:
46+
47+
1. Place your `.pem` key file in the credentials directory:
48+
```bash
49+
cp /path/to/your-aws-key.pem ./credentials/
50+
```
51+
52+
2. Set proper permissions:
53+
```bash
54+
chmod 400 ./credentials/your-aws-key.pem
55+
```
56+
57+
3. Update your `.env` file with the PEM key path:
58+
```
59+
SSH_PRIVATE_KEY_PATH=./credentials/your-aws-key.pem
60+
```
61+
62+
4. Test the connection:
63+
```bash
64+
ssh -i ./credentials/your-aws-key.pem ubuntu@your-ec2-ip
65+
```

0 commit comments

Comments
 (0)