I have several hosts in my ~/.ssh/config file, some of which are on my work network. Before accessing those, I need to authenticate myself on that network by running kinit, but I often forget to do that.
Is there a command to run kinit in a 'before hook' on those SSH hosts?
I'm not sure there's exactly such a thing as a 'before hook', but I can see two hacks that could achieve the a similar effect.
Bash Functions (in some init file like .bashrc, .profile, etc)
ssh ()
{
echo "do this before ssh'ing"
command ssh "$@"
}
The other possibility that I can think on would be the ProxyCommand option. In your ~/.ssh/config:
Host *
ProxyCommand sh -c 'kinit >&2 && nc %h %p'
Couple of salient points:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With