Skip to content

Commit e5f29a2

Browse files
committed
security: disable password authentication by default
Comment out password authentication settings in cloud-init configuration to enforce SSH key-only access for enhanced security. Changes: - Comment out plain_text_passwd field in user configuration - Comment out ssh_pwauth setting - Comment out SSH configuration file that enables password auth - Update final message to reflect SSH key-only access Password authentication can be re-enabled by uncommenting the relevant sections if needed for debugging or recovery purposes.
1 parent ed1bcb0 commit e5f29a2

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

infrastructure/cloud-init/user-data.yaml.tpl

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ users:
2727
sudo: ["ALL=(ALL) NOPASSWD:ALL"]
2828
shell: /bin/bash
2929
lock_passwd: false
30-
plain_text_passwd: torrust123
30+
# plain_text_passwd: torrust123 # Commented out - enable only for debugging/recovery
3131
ssh_authorized_keys:
3232
- ${ssh_public_key}
3333

3434
# Enable SSH password authentication for debugging
35-
ssh_pwauth: true
35+
# ssh_pwauth: true # Commented out - enable only for debugging/recovery
3636

3737
# Package updates and installations
3838
package_update: true
@@ -65,12 +65,13 @@ packages:
6565
# System configuration files
6666
write_files:
6767
# SSH configuration to enable password authentication
68-
- path: /etc/ssh/sshd_config.d/50-cloud-init.conf
69-
content: |
70-
PasswordAuthentication yes
71-
PubkeyAuthentication yes
72-
permissions: "0644"
73-
owner: root:root
68+
# Commented out - enable only for debugging/recovery
69+
# - path: /etc/ssh/sshd_config.d/50-cloud-init.conf
70+
# content: |
71+
# PasswordAuthentication yes
72+
# PubkeyAuthentication yes
73+
# permissions: "0644"
74+
# owner: root:root
7475

7576
# Docker daemon configuration
7677
- path: /etc/docker/daemon.json
@@ -165,7 +166,7 @@ final_message: |
165166

166167
System Information:
167168
- OS: Ubuntu 24.04 LTS
168-
- User: torrust (with sudo privileges and password login)
169+
- User: torrust (with sudo privileges and SSH key access only)
169170
- Docker: Installed and configured
170171
- Firewall: UFW enabled with proper SSH rules
171172
- Security: Automatic updates enabled
@@ -174,7 +175,7 @@ final_message: |
174175

175176
SSH Access:
176177
- SSH Key: ssh torrust@VM_IP
177-
- Password: sshpass -p 'torrust123' ssh torrust@VM_IP
178+
- Password: Disabled for security (can be re-enabled in cloud-init config if needed)
178179

179180
Next steps:
180181
1. SSH into the VM as user 'torrust'

0 commit comments

Comments
 (0)