Ssh – How to use openssh sftp command with a RSA/DSA key specified from the command line

dsarsasftpssh

The Openssh ssh and scp command provied an -i command line option to specify the path to the RSA/DSA key to be used for authentication.

Looking at the sftp man pages I was not able to find a way to specify the RSA/DSA key.

I am looking for a way to do initiate an sftp session that will use a specified RSA/DSA key, and not the ~/.ssh/id_{dsa,rsa} keys.

I tried OpenSSH sftp client on Linux…but it should have the same options on other platforms.

Best Answer

One potential option is to use sftp -oIdentityFile=/path/to/private/keyfile. Need more info to say whether that will work for you. Seems to work under Mac/Linux.