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
First, create an ssh config file. I’m going to put it at
/tmp/exampleUser_ssh_config with the following contents:
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.