Cách SSH vào Raspberry Pi để sử dụng không cần màn hình

TricksMMO

Administrator
Staff member
** Cách SSH thành Raspberry Pi **

**Mục lục**

1. SSH là gì?
2. Vấn đề bảo mật trước khi bật SSH
3. Xem IP hoặc tên máy chủ của Raspberry Pi
4. Phương pháp 1: Bật SSH qua GUI
5. Phương pháp 2: Bật SSH từ thiết bị đầu cuối
6. Tắt gốc SSH
7. Đăng nhập vào Raspberry Pi của bạn từ một máy tính khác

** SSH là gì? **

SSH là viết tắt của vỏ an toàn.Nó cho phép bạn kết nối từ xa với máy chủ hoặc máy tính từ một thiết bị khác bằng cách sử dụng thông tin liên lạc được mã hóa.

Lợi ích chính của SSH là mã hóa dữ liệu.Với các giao thức đăng nhập từ xa kém an toàn hơn, chẳng hạn như FTP, mọi thứ đều được gửi bằng văn bản thuần túy.Một hacker có thể phát hiện giao tiếp đó và ghi lại những thứ như tên người dùng và mật khẩu của bạn.Bởi vì SSH đã được mã hóa, tin tặc sẽ không thể làm như vậy nữa.

** Vấn đề bảo mật trước khi bật SSH **

Bật SSH rất dễ dàng, nhưng bạn cũng nên quan tâm đến một số vấn đề bảo mật.Trước tiên, hãy đảm bảo Raspberry Pi của bạn an toàn bằng cách đặt mật khẩu cho tài khoản người dùng.

Khi bạn lần đầu tiên thiết lập Raspberry Pi, bạn nên thay đổi mật khẩu tài khoản người dùng.Nếu bạn chưa thay đổi mật khẩu, thì bạn cần phải làm điều đó ngay bây giờ.Mở thiết bị đầu cuối, sau đó nhập lệnh `passwd`.

`` `
passwd
`` `

Bạn sẽ được nhắc nhở về mật khẩu hiện tại của bạn, sau đó chọn một mật khẩu mới.

** Xem IP hoặc tên máy chủ của Raspberry Pi **

Bạn cũng sẽ cần biết tên máy chủ hoặc địa chỉ IP của PI của bạn.Nhập lệnh sau vào thiết bị đầu cuối:

`` `
tên máy chủ -i
`` `

Lệnh này sẽ cung cấp địa chỉ IP cho Raspberry Pi của bạn.Địa chỉ đó thường sẽ bắt đầu với 192.168.Ghi lại địa chỉ hoặc tên máy chủ.

Tiếp theo, chúng tôi sẽ bật SSH.

** Phương pháp 1: Bật SSH qua GUI **

Một cách để bật SSH là thông qua giao diện đồ họa của Raspberry Pi.Chỉ cần nhấp vào biểu tượng Raspberry ở góc trên cùng bên trái của màn hình, sau đó nhấp vào ** Tùy chọn ** và chọn ** Cấu hình Raspberry Pi **.

Trong ứng dụng này, nhấp vào tab ** giao diện ** và tìm ** ssh **.Nhấp vào ** Bật **, sau đó nhấp vào ** OK ** để đóng ứng dụng.

** Phương pháp 2: Bật SSH từ thiết bị đầu cuối **

Một phương pháp khác để kích hoạt SSH là từ thiết bị đầu cuối.Nhập lệnh này để bật công cụ cấu hình Raspberry Pi của bạn:

`` `
sudo raspi-config
`` `

Sử dụng các phím mũi tên trên bàn phím của bạn để chọn ** các tùy chọn giao thoa **, sau đó nhấn phím Enter.

Chọn ** P2 SSH ** và nhấn Enter.

Khi được hỏi, "Bạn có muốn bật máy chủ SSH không", chọn ** Có **.Nhấp vào Nhập lại tại hộp xác nhận, ** Máy chủ SSH được bật **, chọn ** Kết thúc **.

** Tắt gốc SSH **

Sau khi bạn đã bật SSH, có một điều không bắt buộc khác bạn nên làm.Cho phép người dùng root có thể SSH vào Raspberry Pi của bạn là rủi ro bảo mật, vì vậy tôi khuyên bạn nên tắt gốc qua SSH.Hãy nhớ rằng bạn luôn có thể phát hành các lệnh quản trị từ người dùng thông thường của bạn với sudo.

Trong cửa sổ thiết bị đầu cuối của bạn, hãy nhập lệnh này:

`` `
nano/etc/ssh/sshd_config
`` `

Bây giờ, hãy tìm dòng này:

`` `
#PermitrootLogin prohibit-password
`` `

Sửa đổi dòng này thành:

`` `
Permitrootlogin số
`` `

Lưu và đóng tệp bằng cách nhấn ** ctrl + x **, sau đó nhấp vào ** y **.Bây giờ, bạn nên khởi động lại máy chủ SSH bằng lệnh này:

`` `
/etc/init.d/sshd Khởi động lại
`` `

Có những bước khác mà bạn có thể làm để bảo mật máy chủ SSH của mình, vì vậy hãy đảm bảo Raspberry Pi của bạn an toàn nhất có thể.

** Đăng nhập vào Raspberry Pi của bạn từ một máy tính khác **

Sau khi các bước đó được hoàn thành, bạn đã sẵn sàng đăng nhập vào Raspberry Pi từ bất kỳ máy tính nào trong mạng cục bộ.Với địa chỉ IP hoặc tên máy chủ bạn đã ghi trước đó, bạn có thể SSH vào PI của mình bằng lệnh sau:

`` `
ssh pi@[địa chỉ
=======================================
**How to SSH into Raspberry Pi**

**Table of Contents**

1. What is SSH?
2. Security problems before turning on SSH
3. See Raspberry Pi's IP or hostname
4. Method 1: Turn on SSH through GUI
5. Method 2: Turn on SSH from Terminal
6. Turn off SSH Root
7. Sign in to your Raspberry Pi from another computer

**What is SSH?**

SSH stands for Secure Shell. It allows you to remotely connect to a server or computer from another device using encrypted communications.

The main benefit of SSH is data encryption. With less secure remote login protocols, such as FTP, everything is sent in plain text. A hacker can detect that communication and record things like your username and password. Because SSH has been encrypted, hackers will not be able to do so anymore.

**Security problems before turning on SSH**

Turning on SSH is easy, but you should also care about some security issues. First, make sure your Raspberry Pi is secure by setting a password for the user account.

When you first set up the Raspberry Pi, you should change the user account password. If you haven't changed your password, then you need to do it right now. Open the Terminal, then enter the `passwd` command.

```
passwd
```

You will be reminded of your current password, then select a new password.

**See Raspberry Pi's IP or hostname**

You will also need to know the hostname or IP address of your Pi. Enter the following command into the Terminal:

```
hostname -i
```

This command will provide the IP address for your Raspberry Pi. That address will usually start with 192.168. Record the address or hostname.

Next, we will turn on SSH.

**Method 1: Turn on SSH through GUI**

One way to turn on SSH is through the Raspberry Pi's graphical interface. Just click the Raspberry icon in the top left corner of the screen, then click **Preferences** and select **Raspberry Pi Configuration**.

In this application, click on the **Interfaces** tab and find **SSH**. Click **Enable**, then click **OK** to close the application.

**Method 2: Turn on SSH from Terminal**

Another method to activate SSH is from Terminal. Enter this command to enable your Raspberry Pi configuration tool:

```
sudo raspi-config
```

Use the arrow keys on your keyboard to select **Interfacing Options**, then press the Enter key.

Select **P2 SSH** and press Enter.

When asked, "would you like the ssh server enabled", select **Yes**. Click Enter again at the confirmation box, **The SSH Server is Enabled**, select **Finish**.

**Turn off SSH Root**

After you have turned on SSH, there is another non-mandatory thing you should do. Allowing ROOT users to be able to SSH into your Raspberry Pi is a security risk, so I recommend that you turn off root via SSH. Remember that you can always issue administrative commands from your usual user with Sudo.

In your Terminal window, enter this command:

```
nano /etc/ssh/sshd_config
```

Now, find this line:

```
#PermitrootLogin Prohibit-Password
```

Modify this line into:

```
PermitrootLogin No
```

Save and close the file by pressing **Ctrl + X**, then clicking **Y**. Now, you should restart the SSH server with this command:

```
/etc/init.d/sshd restart
```

There are other steps that you can do to secure your SSH server, so make sure your Raspberry Pi is as secure as possible.

**Sign in to your Raspberry Pi from another computer**

After those steps are completed, you are ready to log in to your Raspberry Pi from any computer in the local network. With the IP address or server name you have recorded earlier, you can ssh into your pi with the following command:

```
ssh pi@[address
 
Join Telegram ToolsKiemTrieuDoGroup
Back
Top