Skip to content

Commit 45ed950

Browse files
committed
PermitRootLogin in sshd_config, tls provider
1 parent 5afdf77 commit 45ed950

File tree

6 files changed

+27
-13
lines changed

6 files changed

+27
-13
lines changed

.gitignore

+1-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ override.tf.json
3535
# Ignore CLI configuration files
3636
.terraformrc
3737
terraform.rc
38-
terraform
3938
.terraform*
4039

41-
.vscode
40+
logs

README.md

+7-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22

33
Infra for utilizing Hetzner low-cost VPS and Docker containers, wrapped in [Coolify](https://coolify.io) as an all-in-one PaaS, to self-host your own applications, databases, or services.
44

5-
![infra](public/01_infra-diagram.png)
5+
<p align="center">
6+
<img src="public/01_infra-diagram.png" width="600" alt="Infrastructure Diagram">
7+
</p>
8+
69

710
## Prerequisites
811

@@ -47,7 +50,7 @@ Initialize Terraform and apply the configuration:
4750
cd hetzner-infra
4851
terraform init --upgrade
4952
terraform validate
50-
terraform apply -auto-approve
53+
terraform apply
5154
```
5255

5356
### 4. Define hosts and run ansible playbook
@@ -103,5 +106,5 @@ ssh root@<server-ip> -i ~/.ssh/self_hosted_hetzner_key.pem
103106
To destroy the infrastructure run the following command:
104107

105108
```shell
106-
terraform destroy -auto-approve
107-
```
109+
terraform destroy
110+
```

ansible/inventory/hosts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33

44
[coolify-worker]
55
91.107.208.20
6-
128.140.0.112
6+
128.140.0.112

ansible/playbooks/roles/common/tasks/main.yml

+8-2
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,17 @@
4444
name: fail2ban
4545
state: restarted
4646

47+
- name: Ensure no conflicting PermitRootLogin in sshd_config
48+
ansible.builtin.lineinfile:
49+
path: /etc/ssh/sshd_config
50+
regexp: '^PermitRootLogin'
51+
state: absent
52+
4753
- name: SSH Hardening for root user
4854
ansible.builtin.blockinfile:
4955
path: /etc/ssh/sshd_config
5056
block: |
51-
PermitRootLogin yes
57+
PermitRootLogin prohibit-password
5258
PasswordAuthentication no
5359
X11Forwarding no
5460
MaxAuthTries 2
@@ -59,4 +65,4 @@
5965
- name: Restart sshd
6066
ansible.builtin.service:
6167
name: sshd
62-
state: restarted
68+
state: restarted
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
terraform {
22
required_providers {
33
hcloud = {
4-
source = "hetznercloud/hcloud"
4+
source = "hetznercloud/hcloud"
55
version = ">=1.36.0"
66
}
7+
tls = {
8+
source = "hashicorp/tls"
9+
version = ">=4.0.5"
10+
}
711
}
812
}
913

1014
provider "hcloud" {
1115
token = var.hcloud_token
12-
}
16+
}
17+

hetzner-infra/variables.tf

+3-2
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ variable "os_type" {
4343

4444
variable "public_net" {
4545
type = bool
46-
description = "Public network enabled or desabled for all servers besides master_worker and backup"
46+
description = "Public network enabled or desabled for all servers besides controler"
4747
default = true
48-
}
48+
}
49+

0 commit comments

Comments
 (0)