How to copy files on your LAN via SSH

SSH (Secure SHell) is the name of a protocol used to access remote machines over a network. It allows fully control the computer using a command interpreter. Further, SSH allows us to copy data safely (information travels encrypted). So, if you have Linux on both machines and you want to copy data without installing SAMBA, be sure to try this option. You can use it direct from Nautilus!

Using Nautilus

1.- Install openssh-server on the computer with which we want to connect. Actually, if we suppose that at some point we are going to want to connect from the other computer we are currently using, it would be logical to install openssh-server on the 2 (or more) machines.

sudo apt-get install openssh-server

2.- You can restart the compus or run openssh-server.

3.- On the machine from which you are going to control the entire operation, I opened Nautilus and pressed Ctrl + L to be able to write in the address bar. I wrote ssh: // NROIP. The first time you connect to that computer, a message will appear saying that the host's authenticity cannot be carried out. Select the option to proceed further.

4.- It will ask for the username and password with which you want to log into the machine you want to access.

5.- Let's sail! 🙂

From the terminal

1.- In the computer from which you are going to control the entire operation I wrote:

ssh NRO_IP

2.- It will ask for your password and then you will be able to access all the files on the remote computer.

3.- To logout press Ctrl + D (if you have Bash) or write:

logout
In case, after connecting successfully several times, it suddenly refuses to connect. Try deleting the list of known hosts, executing the following command on the computer you want to access from: rm ~ / .ssh / known_hosts.

Using SCP

SCP is an SSH plugin that allows us to copy files quickly and safely.

The syntax is very simple:

scp file user @ server: path
Note: In case you get the error "ssh: Could not resolve hostname earendil-desktop: Name or service not known lost connection", try replacing server with the server's IP number. Thanks to Snocks, we know that it is also possible to add a line, in the format "IP hostname", to the file / Etc / hosts. Ex: 192.168.1.101 earendil-desktop.

To copy in reverse, from the remote computer to yours, I simply reversed the order:

scp user @ server: path / file local_path

That is, for example, if we wanted to send something to the remote computer:

scp list.txt earendil @ earendil-desktop: ~ / miscosas

This command copies the file list.txt from the computer I am using to the ~ / miscosas folder on my remote computer. The owner of this file will be the earendil user (of my remote computer).

To copy entire folders, just add the -r parameter:

scp -r ~ / earendil photos @ earendil-desktop: ~ / miscosas

This command copies the photos folder, located in the HOME of the computer that I am using, to the mythings folder, which is located in the HOME of my remote computer.

Now, the same process in reverse would be:

scp earendil @ earendil-desktop: ~ / my stuff / photos ~

This would copy the ~ / my stuff / photos / folder from the remote computer to the HOME folder on the computer I'm using.

Finally, it is important to note that the default path is your user folder. If you want to copy something to or from there, you can omit the path:

scp list.txt earendil-desktop:

In this case, as the user is repeated on both machines, it is not necessary to type it. Also, I am copying from HOME to HOME, which is why it is not necessary to type the full path of the files either.


Leave a Comment

Your email address will not be published. Required fields are marked with *

*

*

  1. Responsible for the data: Miguel Ángel Gatón
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.

  1.   Carlos del rio said

    Friend, you saved my life, you don't know how much I thank you !!

    Thank you and a thousand thanks !!

  2.   Let's use Linux said

    Hello CaMaRoN! Thanks for the information.
    Of course, that's what this post is about, having access to another pc through SSH. 🙂
    Cheers! Paul.

  3.   Shrimp said

    To access the iPhone through SSH you can do the following: Go to Places / Server and there choose SSH, and fill in the necessary fields.

    Is it possible to use this method to access another pc with linux?

  4.   Felix anadon said

    you can view the contents of another computer with ssh by mounting it in an empty directory.

    sshfs @ /

    It will ask you for the password and you will be able to access the remote_directory in the local directory with commands, nautilus or with any program

  5.   Koringap said

    spectacular was just what I was looking for a few days ago ...

  6.   Shrimp said

    To access the iPhone through SSH you can do the following: Go to Places / Server and there choose SSH, and fill in the necessary fields.

    Is it possible to use this method to access another pc with linux?

  7.   Snocks said

    Very good xd, by the way before this error ...

    Note: In case you get the error "ssh: Could not resolve hostname earendil-desktop: Name or service not known lost connection", try replacing server with the server's IP number.

    in / etc / hosts add the line "IP name"

  8.   Let's use Linux said

    Great! Thanks for the data! I will add it to the post!
    Hug! Paul.

  9.   Screen said

    Very good although I just discovered the rsync command and I liked it better for copying large amounts of files, because if it fails you can continue where you left off.

    Greetings.