Load private key manually with ssh

hsz picture hsz · Dec 8, 2012 · Viewed 10.6k times · Source

Is it possible to run ssh with ignoring default .ssh directory and specify other one or - better - specified private key ?

For example:

ssh --private-key other_id_rsa login@host

Answer

Chris Seymour picture Chris Seymour · Dec 8, 2012

You can use the -i option.

Source: man ssh

-i identity_file
    Selects a file from which the identity (private key) for public key authentication is read.  The default is ~/.ssh/identity for protocol
    version 1, and ~/.ssh/id_dsa, ~/.ssh/id_ecdsa and ~/.ssh/id_rsa for protocol version 2.  Identity files may also be specified on a per-
    host basis in the configuration file.  It is possible to have multiple -i options (and multiple identities specified in configuration
    files).  ssh will also try to load certificate information from the filename obtained by appending -cert.pub to identity filenames.