Terraform: Unable to upload cloudinit snippets via ssh

I’m having trouble uploading snippets. First time doing this, please help.

On my Proxmox PVE I created a user & API key:

sudo pveum user add terraform@pve
sudo pveum role add Terraform -privs "Datastore.Allocate Datastore.AllocateSpace Datastore.AllocateTemplate Datastore.Audit Pool.Allocate Sys.Audit Sys.Console Sys.Modify SDN.Use VM.Allocate VM.Audit VM.Clone VM.Config.CDROM VM.Config.Cloudinit VM.Config.CPU VM.Config.Disk VM.Config.HWType VM.Config.Memory VM.Config.Network VM.Config.Options VM.Migrate VM.Monitor VM.PowerMgmt User.Modify"
sudo pveum aclmod / -user terraform@pve -role Terraform
sudo pveum user token add terraform@pve provider --privsep=0

┌──────────────┬──────────────────────────────────────┐
│ key          │ value                                │
╞══════════════╪══════════════════════════════════════╡
│ full-tokenid │ terraform@pve!provider               │
├──────────────┼──────────────────────────────────────┤
│ info         │ {"privsep":"0"}                      │
├───

Now I’m trying to upload cloud-init yamls for each environment (with replacements from a template file)

provider "proxmox" {
   endpoint  = "https://78.100.100.10:8006"
   api_token = "terraform@pve!provider=<my-api-key>"
   insecure  = true
   
   ssh {
      agent    = true 
      username = "terraform"
   }
}

resource "proxmox_virtual_environment_file" "cloud_init" {
   for_each          = var.VM_CONFIG
   node_name     = "pve"
   content_type  = "snippets"
   datastore_id   = "snippets"

   source_raw {
      data = templatefile("${path.module}/cloud-init-template.yaml", {
         ENVIRONMENT = each.value.ENVIRONMENT
      })
      file_name = "/snippets/snippets/${each.value.ENVIRONMENT}-init.yaml"
   }
}

But when I apply I get the ssh error:

failed to open SSH client: unable to authenticate user “terraform” over SSH to “192.168.100.10:22”. Please verify that ssh-agent is correctly loaded with an authorized key via ‘ssh-add -L’ (NOTE: configurations in ~/.ssh/config are not considered by the provider): failed to dial 192.168.100.10:22: dial tcp 192.168.100.10:22:

First of all, not sure why the error prints my PVE’s internal IP address (192.168.100.10). My provider is set to the external address (78.100.100.10). The only place the internal address is mentioned is at my router level where I forward the external port 22 to the internal address shown in the error. I was surprised to see the internal IP surfaced, but that’s probably unrelated.

The thing is, I’ve already added my jumphost’s sshkey to the pve. That is, ssh-add -L prints the same key as i have in my pve’s ~/.ssh/authorized_keys.

My pve users and realms are as follows:

Then I noticed the documentation says this:

Snippets cannot be uploaded by non-PAM accounts
Due to limitations in the Proxmox VE API, certain files (snippets, backups) need to be uploaded using SFTP. This requires the use of a PAM account (standard Linux account).

Is that what’s affecting me? I tried using an alternative provider like:

provider "proxmox" {
   endpoint  = "https://78.100.100.10:8006"
   password = "<my-pass>"
   username = "root@pam"
   insecure  = true
   
   ssh {
      agent    = true
   }
}

But it gives the same error.

I can succesfully upload files using

sfto [email protected] << EOF
    put cloud-init-template.yaml  /root   
EOF

Why can’t I upload my snippets?

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật