« Back to overview

Here are some useful ssh alias commands. You can add them to
~/.bashrc or ~/.bash_profile

Skip 'known hosts' checks
# 'sshquick' - skip known hosts check (may be unsafe dependent on what you connect to)
alias sshq='ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no '
Connect with identities / key only

This alias allows you to quickly ssh into an instance by directly specifying the key and host. It uses identitiesonly, so it can prevent 'Too many authentication failures' in some cases.

alias sshi='ssh -o IdentitiesOnly=yes -i '

# example: sshi id_rsa [email protected]

If you have many changing hosts, you can disable strict host key checking. This can occur for example if you reinstall a specific device with a new OS, or boot from another drive, but the IP remains the same:

alias sshi='ssh -o IdentitiesOnly=yes -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i '
Connect with password only

Sometimes you want to avoid trying keys by the ssh agent before a 'too many authentication failures' occurs. In that case, this may help:

alias sshp='ssh -p -o PreferredAuthentications=password '
# example: sshp [email protected]

Or, without strict hostkey checking:

alias sshp='ssh -o PreferredAuthentications=password -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no '