Revision: 7565
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at July 30, 2008 04:10 by narkisr
Initial Code
if [ -d ~/.ssh ]; then
# Touch files we expect to exist
if [ ! -e ~/.ssh/config ]; then touch ~/.ssh/config; fi
if [ ! -e ~/.ssh/known_hosts ]; then touch ~/.ssh/known_hosts; fi
# Parse ~/.ssh/known_hosts and ~/.ssh/config to find hosts
for x in `sed -e ’s/[, ].*//’ ~/.ssh/known_hosts; awk ‘/^Host [^*?]+$/{print $2}’ ~/.ssh/config`; do
# Don’t override commands
type $x > /dev/null 2>&1 && continue
alias $x=â€ssh $xâ€
# Remove the domainname
y=${x/.*/}
if [ "$y" != "$x" ]; then
if ! type $y > /dev/null 2>&1; then
alias $y=â€ssh $xâ€
fi
fi
# Remove prefix. Add prefixes you want removed here
y=${y/pf1-/}
y=${y/pf2-/}
if [ "$y" != "$x" ]; then
if ! type $y > /dev/null 2>&1; then
alias $y=â€ssh $xâ€
fi
fi
done
fi
Initial URL
Initial Description
A bash script that auto register ssh aliases of known hosts (as seen at http://blogs.ubuntu-nl.org/dennis/2008/07/29/traincoding-ssh-aliases/).
Initial Title
Auto aliasing of ssh hosts
Initial Tags
Initial Language
Bash