How to Use Linux SFTP Control to Transfer Files
Used to access, manage, and transfer files over an SSH transport.
In Comparison to the FTP protocol, SFTP offers All the functionality of it, also FTP is more easy to configure.
Unlike the scp command, which merely allows file transfers, The sftp command allows you resume file transfers and to carry out a selection of operations on files.
In this tutorial, we will show You How You Can use the Linux sftp command.
Before you Begin
To be able to transfer and manage files via SFTP you must Have write permission on the system.
When It’s Suggested to run the Sftp command within a screen or tmux session.
The directory from where you run the sftp command will be your Local working directory.
Establishing an SFTP link
SFTP functions on a model. It is a subsystem of SSH and supports all SSH authentication mechanisms.
Even Though the password authentication is set up Default and easier to use, in the event that you connect to a server through SSH/SFTP it suggested to make SSH keys and set up a passwordless SFTP login.
To start an SFTP connection to a remote system, use the sftp Command followed by the distant server username along with the IP address or domain name:
If you are connecting to a host using password Authentication password.
Once connected, you will be presented with the sftp prompt, And you can start interacting with the remote server:
Connected to ip_or_hostname.
When the remote SSH server is not listening on the default Jack 22, use the -oPort option to define the alternative port:
Sftp -oPort=custom_port remote_username@server_ip_or_hostname
Most of the SFTP controls are equal or similar to the Commands you would use prompt.
By typing, you can get a listing of all SFTP commands that are available help or ? .
bye Quit sftp
directory to ‘path’
Version Show SFTP version
! local shell
! Escape to local shell
? Synonym for help
Navigating with SFT
When You’re logged in to the server Working directory is the remote user directory. You can check this by scanning:
Remote working directory: /home/remote_username
To navigate to another directory, use the cd command. For Example, to change to the /tmp directory you would type:
The commands are used to navigate and work on the Remote location.
The sftp shell provides commands for navigation that is local, Info and document administration. The local orders are prefixed with the letter l.
For example, to print the working directory, you would Kind:
Local directory: _username
Between two you can move files securely with SFTP machines.
You can use a GUI if you are working on a desktop machine SFTP client like FileZilla or WinSCP to connect to the server and upload or download files.
The sftp command is useful when you work on a host without GUI, and perform other operations on the files that are remote or you also want to transfer files.
Downloading Files using the SFTP Command
Once you are logged in to the remote server Directory is the user home directory that is remote.
When downloading files the files are Downloaded into the directory where the sftp command was typed by you.
To download one file in the remote server, then use the Get control:
The output should look something like this:
Fetching /home/remote_username/filename.zip into filename.zip
/home/remote_username/filename.zip 100% 24MB
If You Would like to save the downloaded file using another Name, specify the new name as the next argument:
To download a directory from the remote system, use the recursive -r option:
Get -r remote_directory
When a file transfer fails or is interrupted, you can restart It using the command.