Browse Source

ssh, clusterssh configs

master
root 1 year ago
parent
commit
6ad11bee64
  1. 3
      eqx-get-deviceid-hostname
  2. 3
      eqx-get-deviceid-ip-private
  3. 3
      eqx-get-deviceid-ip-public
  4. 24
      eqx-get-project-clusterssh-config
  5. 3
      eqx-get-project-names
  6. 14
      eqx-get-project-ssh-config

3
eqx-get-deviceid-hostname

@ -14,7 +14,8 @@ fi
packet \
device get \
--id $EQXDEVICEID | \
--id $EQXDEVICEID \
2>/dev/null | \
grep -v -e '^+' -e "CREATED" | \
cut -f 4 -d " "

3
eqx-get-deviceid-ip-private

@ -16,7 +16,8 @@ fi
packet \
device get \
--json \
--id $EQXDEVICEID | \
--id $EQXDEVICEID \
2>/dev/null | \
jq '.ip_addresses[2].address' | \
sed -e 's/"//g'

3
eqx-get-deviceid-ip-public

@ -16,7 +16,8 @@ fi
packet \
device get \
--json \
--id $EQXDEVICEID | \
--id $EQXDEVICEID \
2>/dev/null | \
jq '.ip_addresses[0].address' | \
sed -e 's/"//g'

24
eqx-get-project-clusterssh-config

@ -0,0 +1,24 @@
#!/bin/bash
# eqx-get-project-ssh-config
#
# Give a project name, generate an ~/.ssh/config snippet.
EQXPROJECT="$1"
if [[ $1 == "" ]]
then \
echo -e "Need project name, such as:\n"
eqx-get-project-names
echo
exit
fi
echo
echo "# Add to ~/.clusterssh/clusters"
echo -n "$EQXPROJECT "
# For each Device, get hostname and IP
for EQXDEVICEID in `eqx-get-project-devices-id "$EQXPROJECT"`
do \
echo -n "`eqx-get-deviceid-hostname $EQXDEVICEID` "
done
echo

3
eqx-get-project-names

@ -1,4 +1,5 @@
#!/bin/bash
eqx-get-projects | jq --raw-output '.[] | {name}' | grep name | cut -f 2 -d ":" | sed -e 's/ //g' -e 's/"//g' | sort -V
eqx-get-projects \
| jq --raw-output '.[] | {name}' | grep name | cut -f 2 -d ":" | sed -e 's/ //g' -e 's/"//g' | sort -V

14
eqx-get-project-ssh-config

@ -13,6 +13,16 @@ if [[ $1 == "" ]]
exit
fi
# Get Project Device IDs
eqx-get-project-devices-id "$EQXPROJECT"
echo
echo "# Add to ~/.ssh/config"
echo "# $EQXPROJECT"
# For each Device, get hostname and IP
for EQXDEVICEID in `eqx-get-project-devices-id "$EQXPROJECT"`
do \
echo "Host `eqx-get-deviceid-hostname $EQXDEVICEID`"
echo -e "\tHostname `eqx-get-deviceid-ip-public $EQXDEVICEID`"
echo -e "\tUser root"
echo -e "\tPort 22"
done
echo

Loading…
Cancel
Save