4. SSH terminal login and network sharing

Video introduction to this chapter:

../../_images/video.png

“13-SSH terminal connected to LubanCat”

https://www.bilibili.com/video/BV1to4y1G7MK/

SSH is a more reliable protocol designed to provide security for remote login sessions and other network services.

注意

The premise of SSH terminal login is that both the computer and the board can be connected and communicated through the network.

Unlike connecting to the Internet, SSH does not need the Internet, as long as the computer and the board form a small network.

4.1. Network plan

  • If you have a router by your side, and your computer is already connected to the router, you can use wifi or a network cable to connect to the router.

  • If you are using a desktop computer, if you have a computer with dual network ports, you can connect one network port to the board, and the other network port to connect to the Internet (configuration method: network sharing below)

  • The computer has a USB interface and a TYPE-C cable that can communicate data. The computer has a network and can share the network through USB.

  • If you are using a laptop, or have a wireless card on a desktop

    1
    2
    3
    Wi-Fi is connected to the Internet, and the network cable is connected to the board (configuration method: network sharing below)
    The network cable is connected to the network, and the computer turns on the hotspot to connect the board
    There are wireless network cards with 2.4G and 5G frequency bands at the same time, you can turn on wifi to connect to the network, and turn on hotspots to connect to the board
    

注意

Most of the chapters in our guide require an Internet connection. If possible, please connect your board to the Internet to give it a soul.

The specific operation method can be found below “Network Deployment”

4.2. Use MobaXterm to log in to the SSH terminal

We also recommend using MobaXterm SSH to log in to the board. This tool is very powerful, not only the functions of SSH and serial port.

4.2.1. SSH login using hostname

This method is only suitable when we do not know the IP of the board

Open the MobaXterm software, click the icon sessions to pop up the session setting, select SSH.

  • The host name of our LubanCat-RK series boards is lubancat, and the following Specify username (designated user) is optional. If you fill it in, you only need to enter the password to log in later.

  • This situation is only suitable for the situation where there is only one LubanCat-RK series board in the LAN. If there are multiple devices, one will be connected randomly.

MobaXterm ssh登录
1
2
 user name:cat
 user password:temppwd
  • If you operate according to the above figure, you only need to enter the password (it will not be displayed in plain text), and then press the confirmation key to enter, as shown in the figure below.

MobaXterm ssh登录

If no user is specified, first enter the user name (will be displayed in plain text), and then enter the password (will not be displayed in plain text)

注意

Pay attention to input method and capitalization

After entering correctly, you will see the following scene

MobaXterm ssh登录

4.2.2. Specify IP - SSH login

When we know the IP of the board, we can specify the IP to log in to the SSH terminal of the board. This method is suitable for when we know the IP of the board.

MobaXterm ssh登录

If we do not specify a user name, we need to enter the user name and password. If we set the user name in advance, we only need to enter the password.

MobaXterm ssh登录

提示

When entering the account password in the serial port terminal and SSH terminal, it will not be displayed in plain text, and we can press the Enter button after the complete input.

4.2.3. Root user - SSH Log in

4.2.3.1. Prepare before login

Our LubanCat image does not support root user SSH login by default. If you want to set SSH login root user, you need to modify the settings.

  • Common user and root user modification method

1
2
3
4
5
6
7
8
9
# 1. modify file /etc/ssh/sshd_config
sudo vi /etc/ssh/sshd_config

# 2.Add at the end of the file PermitRootLogin yes

# 3.save document

# 4.Restart the sshd service
systemctl restart sshd

注解

If the sshd service is restarted during ssh login, enter the password to continue using the terminal.

  • Root user modification method (ordinary users can use the su command to switch, the password is root)

1
2
3
4
5
# 1. modify file /etc/ssh/sshd_config
echo "PermitRootLogin yes" >> /etc/ssh/sshd_config

# 2.Restart the sshd service
systemctl restart sshd

注解

If the sshd service is restarted during ssh login, enter the password to continue using the terminal

4.2.3.2. login root user

The root user SSH login method is the same as that of ordinary users, except that the user name is changed from “cat” to “root”, and the password is changed from “temppwd” to “root”.

注解

For specific operation methods, please refer to the above “SSH login using host name” and “Specify IP - SSH login”

4.3. Network deployment

4.3.1. The network port of the computer is connected to the network-wifi hotspot connected to the wifi of the board card

  1. Left click the Network Icon in the lower right corner

  2. Right click Mobile Hotspot

  3. Left click Settings

wifi

Go to hotspot settings

wifi

4.3.2. Computer wifi networking - board wifi connection wifi hotspot

  1. Left click the Network Icon in the lower right corner

  2. Right click Mobile Hotspot

  3. Left click Settings

wifi

Go to hotspot settings

注意

You need to connect to wifi before you can share the option to use wifi

wifi

4.3.3. Computer wifi Internet access, computer network port connection board

Here is how to enable the network sharing function of the computer.

The following is a simple example of using wifi to access the Internet, and the network port is connected to the board to share the network.

If it is a computer with dual network ports, you can also use this method to set it, but you need to set it according to your needs.

  1. Right-click the network icon in the lower right corner and open the “Network and Internet” settings.

MobaXterm串口登录
  1. Go to Network and Sharing Center

MobaXterm串口登录
  1. Make sure you want to use which connection to the Internet, then click the network you want to connect to the Internet to enter the network settings.

MobaXterm串口登录
  1. Click on properties to enter the settings

MobaXterm串口登录
  1. Click share on the right

MobaXterm串口登录
  1. Select the network you want to share, share to Ethernet here

MobaXterm串口登录

Connect your board to the network port of the computer, and the board can be connected to the Internet through the computer.

4.3.4. Computer USB sharing network

For this method, please refer to the following chapter “Computer USB Shared Network”