Skip to content

Instantly share code, notes, and snippets.

@davegallant
Forked from Xenthys/pct-enter.sh
Created December 3, 2023 04:06
Show Gist options
  • Save davegallant/13c4c6c3d1e0fe28fd373089335ebd48 to your computer and use it in GitHub Desktop.
Save davegallant/13c4c6c3d1e0fe28fd373089335ebd48 to your computer and use it in GitHub Desktop.
A helper for Proxmox's "pct enter" to use containers' hostnames and enter them from any cluster node.
#!/bin/bash
id=$(grep "$1" /etc/pve/.rrd | cut -d'/' -f 2 | cut -d':' -f 1)
[[ "$id" == '' ]] && echo "The specified LXC does not exist." && exit 1
node=$(grep "^\"$id\":" /etc/pve/.vmlist | cut -d'"' -f 6)
[[ $(hostname) != "$node" ]] && pre="ssh -t $node "
echo "Entering LXC $id on node $node..."
${pre}pct enter $id
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment