Skip to content

Instantly share code, notes, and snippets.

@tinoji
Created February 7, 2018 01:02
Show Gist options
  • Save tinoji/7e066d61a84d98374b08d2414d9524f2 to your computer and use it in GitHub Desktop.
Save tinoji/7e066d61a84d98374b08d2414d9524f2 to your computer and use it in GitHub Desktop.
Create and provision Proxmox LXC by pct command
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"
@belov38
Copy link

belov38 commented Oct 22, 2023

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