From 867875d4131410bce4c1e8ee63055d2b3a1ded5c Mon Sep 17 00:00:00 2001 From: David Kebler Date: Thu, 14 Jan 2021 13:26:12 -0800 Subject: [PATCH] updated ssh configs, moved in network related aliases from base. modified sshfs smount function to allow allow default port of 22 --- 238.kebler.net/ssh/config/238.cfg | 135 ++++++++++++++++++++++++ 3115.kebler.net/ssh/config/3115.cfg | 36 +++++++ 645.kebler.net/ssh/config/645.cfg | 152 ++++++++++++++++++++++++++++ all/alias/mint-utils | 4 + all/alias/nas | 4 + all/alias/network | 2 + all/alias/networkd | 15 +++ all/function/nas | 20 ++++ all/modules/sshfs/sshfs.sh | 5 +- 9 files changed, 372 insertions(+), 1 deletion(-) create mode 100644 238.kebler.net/ssh/config/238.cfg create mode 100644 3115.kebler.net/ssh/config/3115.cfg create mode 100644 645.kebler.net/ssh/config/645.cfg create mode 100644 all/alias/mint-utils create mode 100644 all/alias/nas create mode 100644 all/alias/network create mode 100644 all/alias/networkd create mode 100644 all/function/nas diff --git a/238.kebler.net/ssh/config/238.cfg b/238.kebler.net/ssh/config/238.cfg new file mode 100644 index 0000000..29ac7fe --- /dev/null +++ b/238.kebler.net/ssh/config/238.cfg @@ -0,0 +1,135 @@ +AddKeysToAgent yes +ForwardX11 no +ForwardX11Trusted yes +# ForwardAgent yes +IdentityFile ~/.ssh/privatekeys/sysadmin.kebler.net + +######### 238 McHaley Network ################ + +## router + +Host 238gate + user sysadmin + hostname gateway.238.kebler.net + +Host 238gater + user root + hostname gateway.238.kebler.net + +Host 238nas + user sysadmin + hostname nas.238.kebler.net + ForwardX11 yes + +Host 238nasr + user root + hostname nas.kebler.net + ForwardX11 yes + +Host 238water water + user sysadmin + hostname water.238.kebler.net + +Host 238waterr waterr + user root + hostname water.238.kebler.net + +Host 238hass 238ha + user root + hostname hassio.238.kebler.net + port 22 + +Host 238hasshost 238hahost + user root + hostname hassio.238.kebler.net + port 22222 + +Host 238admin trantor + user sysadmin + hostname admin.238.kebler.net + ForwardX11 yes + + +Host 238adminr trantorr + user root + hostname admin.238.kebler.net + ForwardX11 yes + +# Lights Sytem Network +# relays + Host r238lights + user sysadmin + hostname lights.238.kebler.net + port 222 + + Host r238lightsr + user root + hostname lights.238.kebler.net + port 222 + + # switches + Host s238lights + user sysadmin + hostname lights.238.kebler.net + port 122 + + Host s238lightsr + user root + hostname lights.238.kebler.net + port 122 + + # controller + Host 238lights + user sysadmin + hostname lights.238.kebler.net + port 22 + + # root connections + Host 238lightsr + user root + hostname lights.238.kebler.net + port 22 + +## FOR ACCESS WHEN OUTSIDE 238 VIA NAT PORT FORWARDING WHEN VPN IS OFFLINE +Host w238nas + user sysadmin + hostname 238.kebler.net + port 322 + ForwardX11 yes + +Host w238nasf + user sysadmin + hostname 238.kebler.net + port 322 + IdentityFile ~/.ssh/sysadmin.kebler.net + ForwardX11 yes + +Host w238nasr + user root + hostname 238.kebler.net + port 322 + ForwardX11 yes + +## router + +Host w238gate + user sysadmin + hostname 238.kebler.net + IdentityFile ~/.ssh/sysadmin.kebler.net + +Host w238gater + user root + hostname 238.kebler.net + IdentityFile ~/.ssh/sysadmin.kebler.net + +Host wtrantor + user sysadmin + hostname 238.kebler.net + port 222 + IdentityFile ~/.ssh/sysadmin.kebler.net + +Host wtrantorr + user root + hostname 238.kebler.net + port 222 + IdentityFile ~/.ssh/sysadmin.kebler.net diff --git a/3115.kebler.net/ssh/config/3115.cfg b/3115.kebler.net/ssh/config/3115.cfg new file mode 100644 index 0000000..15b8c5a --- /dev/null +++ b/3115.kebler.net/ssh/config/3115.cfg @@ -0,0 +1,36 @@ +Host 3115gate + user sysadmin + hostname 172.31.0.1 + +Host 3115nas + user sysadmin + hostname nas.3115.kebler.net + ForwardX11 yes + +Host 3115admin frodo + user sysadmin + hostname admin.3115.kebler.net + port 22 + ForwardX11 yes + +Host 3115hass + user root + hostname hassio.3115.kebler.net + port 22 + +Host 3115hasshost + user root + hostname hassio.3115.kebler.net + port 22222 + +# via wan/NAT when vpn is down + +Host w3115gate + user sysadmin + hostname i3115.kebler.net + port 22 + +Host wfrodo + user sysadmin + hostname i3115.kebler.net + port 222 diff --git a/645.kebler.net/ssh/config/645.cfg b/645.kebler.net/ssh/config/645.cfg new file mode 100644 index 0000000..a441790 --- /dev/null +++ b/645.kebler.net/ssh/config/645.cfg @@ -0,0 +1,152 @@ +AddKeysToAgent yes +ForwardX11 no +ForwardAgent yes + +########### 645 Broadway Network ################### + +# direct key access lines + # IdentitiesOnly=yes + # IdentityFile ~/.ssh/privatekeys/645-sysadmin + + +# private keys only in keepass not in privatekeys subdirectory + + +## Locally or VPN + +#****** open sprinkler ****# +Host os + user pi + hostname sprinklers.645.kebler.net + port 22 + +# open sprinkler + Host osr + user root + hostname sprinklers.645.kebler.net + port 22 + +Host wnadal + user sysadmin + # change this to 645.kebler.net when deployed + hostname testvpn.kebler.net + port 222 + ForwardX11 yes + +Host nadal + user sysadmin + hostname nadal.645.kebler.net + ForwardX11 yes + +Host nadalr + user root + hostname nadal.645.kebler.net + ForwardX11 yes + +# uses ip in case dns is hosed +Host 645gate + user root + hostname 192.168.0.1 + + +Host 645nas + user sysadmin + hostname nas.645.kebler.net + ForwardX11 yes + +Host 645nasr + user root + hostname nas.645.kebler.net + ForwardX11 yes + + + +# Lights Sytem Network +# relays + Host r645lights + user sysadmin + hostname controller.lights.645.kebler.net + port 222 + + + Host r645lightsr + user root + hostname controller.lights.645.kebler.net + port 222 + + + # switches + Host s645lights + user sysadmin + hostname controller.lights.645.kebler.net + port 122 + + + Host s645lightsr + user root + hostname controller.lights.645.kebler.net + port 122 + + + # controller + Host 645lights + user sysadmin + hostname controller.lights.645.kebler.net + port 22 + + +# controller + Host 645lightsbu + user sysadmin + hostname backup.lights.645.kebler.net + port 22 + + + # root connections + Host 645lightsr + user root + hostname controller.lights.645.kebler.net + port 22 + + + +## Via Internet with Port Forward + +Host w645gate + user sysadmin + hostname i645.kebler.net + +#root login for +Host w645gater + user root + hostname i645.kebler.net + +Host w645nas + user sysadmin + hostname i645.kebler.net + port 322 + +Host w645nasr + user root + hostname i645.kebler.net + port 322 + +Host wnadal + user sysadmin + hostname i645.kebler.net + port 222 + +Host wnadalr + user root + hostname i645.kebler.net + port 222 + +Host 645ha 645hass + user root + hostname hassio.645.kebler.net + port 22 + +Host 645hahost 645hasshost + user root + hostname hassio.645.kebler.net + port 22222 diff --git a/all/alias/mint-utils b/all/alias/mint-utils new file mode 100644 index 0000000..0cb0ccc --- /dev/null +++ b/all/alias/mint-utils @@ -0,0 +1,4 @@ +# run this on remote machine via ssh x11 forwarding +alias rmintupdate='XAUTHORITY=$HOME/.Xauthority sudo -E mintupdate' +alias rsources='XAUTHORITY=$HOME/.Xauthority sudo -E software-sources' +alias rsynaptic='XAUTHORITY=$HOME/.Xauthority sudo -E synaptic' diff --git a/all/alias/nas b/all/alias/nas new file mode 100644 index 0000000..1c3486e --- /dev/null +++ b/all/alias/nas @@ -0,0 +1,4 @@ +# nas +alias naslist="echo nasfm nasdisk nasgparted nasdata, caddyr, caddye" +alias nasha="ssh -t nas 'cd /usr/share/hassio/homeassistant ; bash'" +alias nascaddy="ssh -t nas 'cd /opt/caddy ; bash'" diff --git a/all/alias/network b/all/alias/network new file mode 100644 index 0000000..cb1867f --- /dev/null +++ b/all/alias/network @@ -0,0 +1,2 @@ +alias ports="netstat -tulpn" +alias flushdns="systemctl restart systemd-resolved" diff --git a/all/alias/networkd b/all/alias/networkd new file mode 100644 index 0000000..d2ff3ad --- /dev/null +++ b/all/alias/networkd @@ -0,0 +1,15 @@ +alias nws="sudo systemctl start systemd-networkd" +alias nwe="sudo systemctl enable systemd-networkd" +alias nwd="sudo systemctl disable systemd-networkd" +alias nwstp="sudo systemctl stop systemd-networkd" +alias nwr="sudo systemctl restart systemd-networkd" +alias nwdst="systemctl status systemd-networkd" +alias nwj="journalctl -u systemd-networkd" +alias nw="networkctl" +alias nwst="networkctl status" +alias nwl="networkctl lldp" + +alias nid="sudo ip link set down" +alias niu="sudo ip link set up" +alias nir1="nid eth1 && niu eth1 && nwr" +alias nir1="nid eth1 && niu eth1 && nwr" diff --git a/all/function/nas b/all/function/nas new file mode 100644 index 0000000..94d09f4 --- /dev/null +++ b/all/function/nas @@ -0,0 +1,20 @@ +# nas + +## rrem already loaded in 00-basic + +function nasfm(){ + rrem sysadmin@nas.kebler.net "nemo "$1"" +} + +function nasdisk(){ + rrem sysadmin@nas.kebler.net "sudo gnome-disks" +} + + +function nasgparted(){ + rrem sysadmin@nas.kebler.net "sudo gparted" +} + +function nasdata(){ + rrem sysadmin@nas.kebler.net "nemo /mnt/data" +} diff --git a/all/modules/sshfs/sshfs.sh b/all/modules/sshfs/sshfs.sh index fe731cb..f5e686d 100755 --- a/all/modules/sshfs/sshfs.sh +++ b/all/modules/sshfs/sshfs.sh @@ -5,8 +5,11 @@ module_load net-utils # host_reachable function smount(){ local HOST +local PORT HOST=$(sed 's/.*@\(.*\):.*/\1/' <<< "$1") -[[ ! $(host_reachable $HOST 22) ]] && echo host $HOST not reachable, aborting mount && return 1 +# TODO search for -p and extract port, this assumes 3 and 4 position +PORT=$([[ $3 = "-p" ]] && echo $4 || echo 22) +[[ ! $(host_reachable $HOST $PORT) ]] && echo host $HOST not reachable, aborting mount && return 1 if [[ $(mounted $2) ]]; then echo "remote $1 already mounted at $2, aborting mount" else