do non root user doc
This commit is contained in:
@@ -147,6 +147,7 @@ export default defineConfig({
|
|||||||
link: '/opentofu/',
|
link: '/opentofu/',
|
||||||
collapsed: true,
|
collapsed: true,
|
||||||
items: [
|
items: [
|
||||||
|
{ text: 'Digital Ocean Droplet Creation', link: '/opentofu/digital-ocean-droplet-non-root-user' },
|
||||||
{ text: 'Encrypted State', link: '/opentofu/encrypted-state' },
|
{ text: 'Encrypted State', link: '/opentofu/encrypted-state' },
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|||||||
27
docs/opentofu/digital-ocean-droplet-non-root-user.md
Normal file
27
docs/opentofu/digital-ocean-droplet-non-root-user.md
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
# Digital Ocean Droplet Non Root User
|
||||||
|
|
||||||
|
Digital Ocean droplets usually have a default user which is root, which is not ideal for security reasons. The following userdata script can be used to create a non-root user and set up SSH access for that user. This is typically used when creating a droplet with Terraform or any other infrastructure as code tool that supports user data.
|
||||||
|
|
||||||
|
```tf
|
||||||
|
data "digitalocean_ssh_key" "default" {
|
||||||
|
name = "my-ssh-key"
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "digitalocean_droplet" "example" {
|
||||||
|
# ... other droplet configuration ...
|
||||||
|
|
||||||
|
user_data = <<-EOF
|
||||||
|
#cloud-config
|
||||||
|
users:
|
||||||
|
- name: reach
|
||||||
|
groups: sudo
|
||||||
|
shell: /bin/bash
|
||||||
|
sudo: ALL=(ALL) NOPASSWD:ALL
|
||||||
|
ssh-authorized-keys:
|
||||||
|
- ${data.digitalocean_ssh_key.default.public_key}
|
||||||
|
|
||||||
|
disable_root: true
|
||||||
|
package_update: true
|
||||||
|
package_upgrade: true
|
||||||
|
EOF
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user