< All Topics

Remote Directory with SFTP

When a user connects using SFTP the remote/target directory must be set on the client side due to the way the SFTP protocol works. This means the end-user must specify the shared folder name in their SFTP script or software.

Please note that the default directory that you can set server-side on a Users profile is effective when using HTTPS, FTP or FTPS however not for SFTP. SFTP softwares will include a field called “Remote default directory” or similar description on their configuration or options pages. 

Our best practice when giving out SFTP connection details is to include:

  • Hostname
  • Username
  • Password
  • Name of shared folder/remote default directory

This will allow the user to input the remote directory upon initial configuration of their SFTP software.

Scripting with SFTP

If the user is using a scripted approach, they would need to issue a change directory command before initiating a file transfer command.

For example, You are trying to login to your Hosted~FTP~ account to download a file called “test.txt” in a folder called “article”

Your script will look like this:

>> sftp username@hostname
For example sftp hostedftptutorial@ftp.hostedftp.com

>>Password or the file path if you are using a PKI key pair (more info here).

>> Remote command to change directory “CD remote folder”
For example “cd article”

Then to download the folder, you run the command
>> Get “test.txt”

More Resources

Table of Contents