_khfix_common() {
local host ip port
- read -r host ip port < <(timeout -s 9 2 ssh -oBatchMode=yes -oControlMaster=no -oControlPath=/ -v $1 |& sed -rn "s/debug1: Connecting to ([^ ]+) \[([^\]*)] port ([0-9]+).*/\1 \2 \3/p" || [[ $? == 124 ]])
+ read -r host ip port < <(timeout -s 9 2 ssh -oBatchMode=yes -oControlMaster=no -oControlPath=/ -v $1 |& sed -rn "s/debug1: Connecting to ([^ ]+) \[([^\]*)] port ([0-9]+).*/\1 \2 \3/p" ||: )
if [[ ! $ip ]]; then
echo "khfix: ssh failed"
return 1
host_entry=$host
fi
if [[ $host != $ip ]]; then
- ssh-keygen -R "$host_entry" -f $(readlink -f ~/.ssh/known_hosts)
+ m ssh-keygen -R "$host_entry" -f $(readlink -f ~/.ssh/known_hosts)
+ ll ~/.ssh/known_hosts
fi
- echo "khfix: removing key for $ip_entry"
- ssh-keygen -R "$ip_entry" -f $(readlink -f ~/.ssh/known_hosts)
+ m ssh-keygen -R "$ip_entry" -f $(readlink -f ~/.ssh/known_hosts)
+ ll ~/.ssh/known_hosts
rootsshsync
}
khfix() { # known hosts fix
}
ccat () { # config cat. see a config without extra lines.
- grep '^\s*[^;[:space:]#]' "$@" || [[ $? == 1 ]]
+ sed -r '/^[[:space:]]*([;#]|--|\/\/|$)/d' "$@"
}
ccomp grep ccat
echo "$help"
return
fi
- x=$(s ps -eF)
+ x=$(ps -eF)
# final grep is because some commands tend to have a lot of trailing spaces
y=$(echo "$x" | grep -iP "$@" | grep -o '.*[^ ]') ||:
if [[ $y ]]; then
import secrets
print(secrets.SystemRandom().randrange(10002,65500))
EOF
- }
+}
# reapply bashrc
reb() {
ser() {
if type -p systemctl &>/dev/null; then
- s systemctl $1 $2
+ s systemctl "$@"
else
+ if (( $# >= 3 )); then
+ echo iank: ser expected 2 or less arguments
+ return 1
+ fi
s service $2 $1
fi
}