2023年1月6日 星期五

Detect if a VM is running in Google Compute Engine

Detect if a VM is running in Compute Engine

sudo dmidecode -s system-product-name | grep "Google Compute Engine"
這個需要 root 權限,實際上是去讀取 /sys/firmware/dmi/tables/DMI
用 strings /sys/firmware/dmi/tables/DMI | grep "Google Compute Engine" 也行

若程式沒有 root 權限,可以去讀取 /etc/hosts 有沒有包含 Added by Google 字樣
grep "Added by Google" /etc/hosts

沒有留言:

scp remote to remote

有 3 台主機 HostA、HostB、HostC 在 HostC 下 scp 指令要從 HostA 複製檔案到 HostB,都透過 Key auth 預設情況下 (沒有加參數 -3) HostC 對 HostA 要建 Key,HostA 對 hostB 要建 Key 資料流是直...