-
I am trying to create vm templates based on the example in the docs.
When I use the username and password of the host user I'm connecting via ssh, I get:
When I use the username and password of the pve user with 'root@pam` username, I get:
The terraform code for reference: # main.tf
provider "proxmox" {
endpoint = var.api_url
api_token = var.api_token
insecure = true
random_vm_ids = true
random_vm_id_start = 90000
random_vm_id_end = 90999
ssh {
agent = true
username = "username"
password = "******"
node {
name = var.proxmox_host
address = "192.168.1.67"
}
}
}
# modules/ubuntu-template/main.tf
resource "proxmox_virtual_environment_vm" "ubuntu-template" {
name = var.name
node_name = var.node_name
template = true
started = false
machine = "q35"
bios = "ovmf"
description = "Managed by Terraform"
cpu {
cores = 2
}
memory {
dedicated = 2048
}
efi_disk {
datastore_id = var.datastore_id
type = "4m"
}
disk {
datastore_id = var.datastore_id
file_id = proxmox_virtual_environment_download_file.ubuntu_cloud_image.id
interface = "virtio0"
iothread = true
discard = "on"
size = 20
}
initialization {
datastore_id = var.datastore_id
user_account {
keys = [var.ssh_key]
username = var.username
password = ""
}
ip_config {
ipv4 {
address = "dhcp"
}
}
}
network_device {
bridge = "vmbr0"
}
}
resource "proxmox_virtual_environment_download_file" "ubuntu_cloud_image" {
content_type = "iso"
datastore_id = var.datastore_id
node_name = var.node_name
url = "https://cloud-images.ubuntu.com/jammy/current/jammy-server-cloudimg-amd64.img"
} |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Hey @maskudo 👋🏼
Not sure what do you mean by each "user" here 😅, Let's assume you have privileged "root" and unprivileged "username" OS-level (aka PAM) user accounts on the PVE host.
Also from the doc:
So the However, the Then according to the configuration above, you should be able to ssh to PVE as "username" without asking for a password, and should be able to run commands either derectly ( You still have an option to use "root" user instead of "username", but again, you should be able ssh to PVE as root without the password. If you don't want to use the ssh agent, then set it to false, and use the password instead. |
Beta Was this translation helpful? Give feedback.
-
I am using a nixos flavour of proxmox and I seem to have gotten my sshd permissions wrong. Wasn't allowing password based ssh connection. |
Beta Was this translation helpful? Give feedback.
Hey @maskudo 👋🏼
Not sure what do you mean by each "user" here 😅, Let's assume you have privileged "root" and unprivileged "username" OS-level (aka PAM) user accounts on the PVE host.
agent = true
means the provider will be using SSH Agent on the machine where you're running terraform from to authenticate over SSH with the PVE host. Do you have the agent up and running with keys loaded?Also from the doc: