Bootstrap FreeKB - FTP and Secure FTP (FTPS, SFTP) - upload a file or directory using the put command
FTP and Secure FTP (FTPS, SFTP) - upload a file or directory using the put command


There are a number of ways to securely transfer files between systems.

  • The PSFTP command line tool can be used to for SFTP (Secure FTP) to securetly transfer files between systems, from a remote system to your PC, or vice versa. This has the advantage of being able to transfer files between Linux, Mac and Windows systems.
  • The scp command (Secure Copy Protocol) could be used to securely transfer files between Linux systems.

There are a number of different tools that can be used to connect to an FTP / FTPS / SFTP server.

  • Windows or Linux command line prompt
  • Scripting tool (e.g. Bash, Perl, PowerShell, Python, et cetera)
  • The PSFTP command line tool PSFTP.exe (see Installing PuTTY PSFTP)

Let's say you want to transfer C:\Users\john.doe\foo.txt from your local PC to the remote FTP system. Use the put command to transfer the file. If you only specify the file on your local PC, the file will be uploaded to the present working directory on the remote FTP system.

ftp > put C:\Users\john.doe\foo.txt
local: C:\Users\john.doe\foo.txt => remote:/tmp/foo.txt

 

The mput command can be used to upload multiple files or directories.

Or you can include the directory and file name for the file on the remote FTP system.

ftp > put C:\Users\john.doe\foo.txt /tmp/bar.txt
local: C:\Users\john.doe\foo.txt => remote:/tmp/bar.txt

 

Likewise, the put command can be used to transfer a directory and the contents of the directory from your local system to the remote system, optionally giving the directory a different name on the remote system. In this example, the "foo" directory is transferred to the remote system and renamed to "bar" on the remote system.

ftp > put -r C:\Users\john.doe\foo /tmp/foo
local: C:\Users\john.doe\foo => remote:/tmp/foo

 

When the upload has completed, you should simply be presented with the prompt again. Use the dir (directory) command or ls (list) command to list the contents of the present working directory on the remote FTP system, to verify that the file or directory was successfully transferred.

ftp > ls
-rw-rw-r--   1   john.doe john.doe   50   Dec 4 19:07   foo.txt

 

Or, the lpwd (local present working directory) command can be used to determine your current working directory on your local PC (not on the remote FTP system).

ftp> lpwd
Current local directory is C:\Program Files (x86)\PuTTY

 

If you need to change your local working directory, use the lcd (local change directory) command to move into the C:\Users\john.doe directory on your local PC (not on the remote FTP system).

ftp> lcd C:\Users\john.doe
New local directory is C:\Users\john.doe

 

Use the pwd (remote present working directory) command to determine your current working directory on the remote FTP system (not on your local PC).

ftp> pwd
Remote directory is /home/john.doe

 

If you need to change the working directory on the remote FPT system, use the cd (change directory) command.

ftp> cd /tmp
Remote directory is now /tmp

 

Use the exit command to disconnect.

ftp > exit

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter 0a050c in the box below so that we can be sure you are a human.