Linux tutorial 5 - SSH and SCP: Safe connection with other machines

In this tutorial, I will introduce how to login and trasfer files to the remote linux system. Here I use the ssh, secure shell, to login and use scp, secure copy protocol to achieve the goal.

Putty: windows login Ubuntu

Now, I will show how to login remote linux system (guest) from windows (host). The software “Putty” is the most simplest way to build the connection.

By default, the network in VMware is shared by NAT (a mechanism to transfer IPs) from host. This cause that the host and the guest are in different local internet. However, SSH connections can only be built if both of the original and the target are in the same local internet. More of the fundamental concepts of the internet will maybe discussed in the future.

The previous work is to change the network setting from “NAT” to “bridged” so that we can ensure both of the original (host) and the target (guest) are in the same local internet. This step is only for the connection between real machine and virtual machine. For two real machine, we just need to use an internet cable to link them together or use two cables to link them to a router.

Now we can start the connection.

  1. Ubuntu guest: Install the net-tools to check the IP and openssh-server to launch the server.

    1
    2
    3
    sudo apt install net-tools 
    sudo apt install openssh-server
    ifconfig

  2. Windows host: Downlaod the .msi of Putty.

  3. (Optional) Windows host: Open CMD, and type ipconfig to see host IP.

    The step is unncessesey cuz the SSH connection doesn’t need the host IP. However, it can help us to check that both of host and guest are in same local internet if you know to verify it. The other way is to use the host terminal to ping the guest IP. e.g. ping 192.168.0.200. The SSH connection will suceed only if the ping suceed.

  4. Windows host: Open Putty and type the guest IP to connect. Press True to the alert as well as type username and password to login.

Now you can control the remote computer.

SCP: transfer files

The SCP tools is the simplest method to transfer the file through SSH channel.

  1. Windows host: Install Git

  2. Windows host: Create an example file transfer.txt and open git bash in the same folder.

  3. Windows host: Type the following command

    1
    scp <file> <target_user>@<target_IP>:<target_path>

  4. Ubuntu guest: Verify the file has been sent to the guest.