TapeTrack Documentation

Because there is more to tape management than you ever realized

User Tools

Site Tools


technote:sftp

This is an old revision of the document!


Transferring files via SFTP

Linux

The Linux sftp command does not provide an argument to specify a password. If you do not want to configure keys for the transfer, you can install the sshpass program.

[root@corp-01 ~]# yum install sshpass
Last metadata expiration check: 0:04:14 ago on Fri 19 Apr 2019 04:22:49 PM MDT.
Dependencies resolved.
=========================================================================================================================================================================================================================================
 Package                                                 Arch                                                   Version                                                     Repository                                              Size
=========================================================================================================================================================================================================================================
Installing:
 sshpass                                                 x86_64                                                 1.06-4.fc27                                                 fedora                                                  26 k

Transaction Summary
=========================================================================================================================================================================================================================================
Install  1 Package

Total download size: 26 k
Installed size: 38 k
Is this ok [y/N]: y
Downloading Packages:
sshpass-1.06-4.fc27.x86_64.rpm                                                                                                                                                                           1.4 MB/s |  26 kB     00:00    
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                                                                                    196 kB/s |  26 kB     00:00     
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                                                                                                                 1/1 
  Installing       : sshpass-1.06-4.fc27.x86_64                                                                                                                                                                                      1/1 
  Running scriptlet: sshpass-1.06-4.fc27.x86_64                                                                                                                                                                                      1/1 
  Verifying        : sshpass-1.06-4.fc27.x86_64                                                                                                                                                                                      1/1 

Installed:
  sshpass.x86_64 1.06-4.fc27                                                                                                                                                                                                             

Complete!

Once sshpass is installed, you can call sshpass, pass the password and then pass the sftp command string as an argument.

To specify multiple command strings you can either pass a file fill of commands, or you can use the bash here-string syntax.

[root@corp-01 ~]# sshpass -p "password" sftp user@server.tapetrack.com <<< "put drm.csv upload/drm.csv"
Connected to server.tapetrack.com.
sftp> put drm.csv upload/drm.csv

technote/sftp.1555713373.txt.gz · Last modified: 2025/01/21 22:07 (external edit)