File tree Expand file tree Collapse file tree 3 files changed +87
-1
lines changed Expand file tree Collapse file tree 3 files changed +87
-1
lines changed Original file line number Diff line number Diff line change
1
+ MACHINE_IP = 45.55.184.5
2
+ MACHINE_USER = root
3
+ SSH_PRIVATE_KEY_PATH = ./credentials/ansible_hub_key
Original file line number Diff line number Diff line change
1
+ # Ansible
2
+ * .retry
3
+ * .pyc
4
+ __pycache__ /
5
+
1
6
# Ignore Ansible Vault files
2
7
* .vault
3
8
8
13
# Ignore other common files
9
14
* .swp
10
15
* .swo
16
+
17
+
18
+ # OS generated files
11
19
.DS_Store
20
+ .DS_Store ?
21
+ ._ *
22
+ .Spotlight-V100
23
+ .Trashes
24
+ ehthumbs.db
12
25
Thumbs.db
13
26
27
+ # Environment variables
14
28
.env
15
29
30
+ # Credentials
16
31
credentials /*
17
32
! 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
Original file line number Diff line number Diff line change
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
+
1
9
``` bash
2
10
cd credentials
3
11
ssh-keygen -t rsa -b 2048 -f " $( pwd) /ansible_hub_key"
4
12
```
5
13
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
6
21
``` bash
7
- ssh -i ./ansible_hub_key root@167.172.25.133
22
+ ssh -i ./ansible_hub_key root@your-server-ip
8
23
```
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
+ ```
You can’t perform that action at this time.
0 commit comments