sftp and secure file transfer to remote computers

sftp command

SFTP (Secure File Transfer Protocol) is a secure version of FTP (File Transfer Protocol) that is used to transfer files between a client and a server. It is often used to transfer files between a local machine and a remote server, or between two remote servers.

To use SFTP, you will need to have an SFTP client installed on your local machine. There are many different SFTP clients available, including command-line tools such as sftp and graphical user interface (GUI) tools such as FileZilla.

Once you have an SFTP client installed, you can connect to an SFTP server by specifying the server’s hostname or IP address and your login credentials. For example, you might use a command like this to connect to an SFTP server using the sftp command-line tool:

sftp user@example.com

Here are some common commands that you can use while connected to a remote server via sftp:

ls: Lists the files and directories in the current directory on the remote server.

cd: Changes the current directory on the remote server.

pwd: Displays the current directory on the remote server.

put: Copies a file from your local machine to the remote server.

get: Copies a file from the remote server to your local machine.

mkdir: Creates a new directory on the remote server.

rmdir: Deletes an empty directory on the remote server.

rm: Deletes a file on the remote server.

Here are some examples of using these commands:

To list the files in the current directory on the remote server:

$ ls

To change the current directory on the remote server:

$ cd path/to/directory

To display the current directory on the remote server:

$ pwd

To copy a file from your local machine to the remote server:

$ put local_file

To copy a file from the remote server to your local machine:

$ get remote_file

To create a new directory on the remote server:

$ mkdir new_directory

To delete an empty directory on the remote server:

$ rmdir directory

To delete a file on the remote server:

$ rm file

 

After connecting to the SFTP server, you will be able to use various SFTP commands to transfer files and perform other tasks also on local computer.

The “lls” command is a local version of the “ls” command, which is used to list the files and directories in a directory. It is used to list the files and directories on the local machine, rather than on the remote server.

The “lcd” command is a local version of the “cd” command, which is used to change the current working directory. It is used to change the current working directory on the local machine, rather than on the remote server.

The “lmkdir” command is a local version of the “mkdir” command, which is used to create a new directory. It is used to create a new directory on the local machine, rather than on the remote server.

The “lrm” command is a local version of the “rm” command, which is used to delete files and directories. It is used to delete files and directories on the local machine, rather than on the remote server.

Here are a few examples of how you might use these commands after logging in to an SFTP server:

To list the files and directories in the current working directory on the local machine, you might use the “lls” command like this:

$ lls

To change the current working directory on the local machine to “/home/user/documents”, you might use the “lcd” command like this:

$ lcd /home/user/documents

To create a new directory called “files” on the local machine, you might use the “lmkdir” command like this:

$ lmkdir files

To delete the file “oldfile.txt” on the local machine, you might use the “lrm” command like this:

$ lrm oldfile.txt

Keep in mind that these commands only work on the local machine, and will not affect the remote server. To perform similar tasks on the remote server, you will need to use the appropriate SFTP commands.

 

License

Developers ultimate guide: Linux Bash scripting Copyright © 2022 by Matin Maleki. All Rights Reserved.

Share This Book