Those warnings usually pop up only the first time, browsers usually remember that you trust it. What could do is get a certificate from Let's encrypt, you can set that up in the Web UI just select the plugin for the DNS provider you are using, and PVE does the DNS challenge automatically[1]. Assuming you have a domain name, without one you also can't get a trusted certificate for one. As an alternative you could tell your browser to trust the CA PVE used for signing the certificate, for that you can follow[2].
[1]
https://pve.proxmox.com/wiki/Certificate_Management
[2]
https://pve.proxmox.com/wiki/Import_certificate_in_browser
Thank you very much, but I have found that my substantive issue has not been resolved. I need to reorganize my requirements. I actually want to write a script and control Proxmox to batch shut down or start certain virtual machines. But I encountered a new problem first, which is that I kept reporting 401 permission issues during the request. Can you help me take a look at this problem? My specific Python code is as follows:
import requests
# Proxmox VE 主机的相关信息
proxmox_host = "192.138.4.200"
proxmox_user = "root@pam"
proxmox_password = "iecas1222"
proxmox_node = "iecas"
# 获取 Proxmox 登录票据
def get_ticket():
login_url = f"https://{proxmox_host}:8006/api2/json/access/ticket"
login_data = {
'username': proxmox_user,
'password': proxmox_password,
}
response = requests.post(login_url, data=login_data, verify=False)
ticket_data = response.json()
result=ticket_data.get('data', {}).get('ticket')
return result
# 关机虚拟机
def shutdown_vm(vmid):
ticket = get_ticket()
if ticket:
shutdown_url = f"https://{proxmox_host}:8006/api2/json/nodes/{proxmox_node}/qemu/{vmid}/status/shutdown"
headers = {'CSRFPreventionToken': ticket}
response = requests.post(shutdown_url, headers=headers, verify=False)
print(response)
if response.status_code == 200:
print(f"虚拟机 {vmid} 已关机")
else:
print(f"无法关机虚拟机 {vmid}")
# 批量关机虚拟机
def batch_shutdown_vms(vm_list):
for vmid in vm_list:
shutdown_vm(vmid)
# 虚拟机ID列表
vm_ids_to_shutdown = [109] # 你的虚拟机ID列表
# 执行批量关机
batch_shutdown_vms(vm_ids_to_shutdown)