Software Engineer

sftp – specify the private key

· by jsnby · Read in about 1 min · (96 Words)
Computers

I’m going to assume that we need to sync some files to a remote server called sftp.example.com as the user exampleUser and use a private ssh key located at /tmp/exampleUser_id_rsa

First, create an ssh config file. I’m going to put it at /tmp/exampleUser_ssh_config with the following contents:

IdentityFile /tmp/exampleUser_id_rsa

Then, initiate your sftp command, but add the -F flag:

sftp -F /tmp/exampleUser_ssh_config exampleUser@sftp.example.com

Why would you do this? Perhaps you don’t want to create a user called exampleUser on your system, or perhaps you don’t want to use your default ssh key for the file transfer.