Search code examples
centossftpopenssh

OpenSSH sftp 'put' with a trailing slash on the source folder or not?


I need to copy a directory (/local_backups) containing database backups from my CentOS server to an offsite SFTP server. But I am uncertain about something:
Should I run the command with a trailing slash after the source folder or not?

Should it be A or B?

A. sftp> put -r /local_backups

B. sftp> put -r /local_backups/

I have searched many forums and cannot find anything specific to sftp commands.


Solution

  • It does not matter. In both cases, it behaves as if the path was ending with the slash:

    sftp> put -r /local_backups
    Uploading /local_backups/ to /
    Entering /local_backups/
    
    sftp> put -r /local_backups/
    Uploading /local_backups/ to /
    Entering /local_backups/