Created
February 7, 2018 01:02
-
-
Save tinoji/7e066d61a84d98374b08d2414d9524f2 to your computer and use it in GitHub Desktop.
Create and provision Proxmox LXC by pct command
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pct create <id> /var/lib/vz/template/cache/centos-7-default_20170504_amd64.tar.xz \ | |
-arch amd64 \ | |
-ostype <centos|ubuntu|etc> \ | |
-hostname <hostname> \ | |
-cores <cores> \ | |
-memory <memory(MB)> \ | |
-swap <swap(MB)> \ | |
-storage local-lvm \ | |
-password \ | |
-net0 name=eth0,bridge=<bridge>,gw=<gateway>,ip=<cidr>,type=veth &&\ | |
pct start <id> &&\ | |
sleep 10 &&\ | |
pct resize <id> rootfs <storage(ex: +4G)> &&\ | |
pct exec <id> -- bash -c "yum update -y &&\ | |
yum install -y openssh-server &&\ | |
systemctl start sshd &&\ | |
useradd -mU hogeuser &&\ | |
echo "password" | passwd --stdin hogeuser" | |
Here is my example using DHCP and defining volume size, my storage name is main
pct create <id> /data/template/cache/debian-11-standard_11.3-1_amd64.tar.zst \
-ostype <debian|centos|etc> \ \
-hostname <hostname> \
-cores <cores> \
-memory <memory(MB)> \
-swap <swap(MB)> \
-rootfs volume=main:<sizeInGB> \
-net0 name=eth0,bridge=<bridge>,ip=dhcp,hwaddr=<macaddr format 00:00:00:00:00:00>
pct start <id>
pct exec <id> -- mkdir -p /root/.ssh/
pct push <id> ~/.ssh/authorized_keys /root/.ssh/authorized_keys
You can use a param -ssh-public-keys
to push your keys during creating
# pct help create
...
-ssh-public-keys <filepath>
Setup public SSH keys (one key per line, OpenSSH format).
...
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thanks