Ask [Lớp học lập trình] Bài 3: Project SSH All In One - Part 1 2 3

Proxy4G8

New member
### [Lớp lập trình] Bài 3: Dự án SSH Tất cả trong một - Phần 1

** Hashtags: ** #SSH #Programming #Tutorial #linux #NetWorking

**Giới thiệu**

Trong bài học này, chúng tôi sẽ tiếp tục dự án tạo một máy chủ SSH duy nhất có thể được sử dụng để truy cập nhiều máy.Trong bài học trước, chúng tôi đã tạo một máy chủ SSH cơ bản và cấu hình nó để cho phép người dùng đăng nhập bằng các khóa SSH của họ.Trong bài học này, chúng tôi sẽ thêm các tính năng bổ sung vào máy chủ SSH của mình, chẳng hạn như khả năng tạo và quản lý người dùng và khả năng giới hạn quyền truy cập vào các máy cụ thể.

** Tạo và quản lý người dùng **

Điều đầu tiên chúng tôi cần làm là tạo một số người dùng cho máy chủ SSH của chúng tôi.Để làm điều này, chúng ta có thể sử dụng lệnh `useradd`.Lệnh sau sẽ tạo người dùng có tên `bob` với mật khẩu của` password`:

`` `
UserAdd Bob
Bob Passwd
`` `

Khi chúng tôi đã tạo người dùng, chúng tôi có thể sử dụng lệnh `usermod` để thay đổi mật khẩu, thư mục gia đình hoặc các cài đặt khác.Ví dụ: lệnh sau sẽ thay đổi mật khẩu cho người dùng `bob` thành` newpassword`:

`` `
usermod -p newpassword bob
`` `

Chúng ta cũng có thể sử dụng lệnh `userDel` để xóa người dùng.Lệnh sau sẽ xóa người dùng `bob`:

`` `
UserDel Bob
`` `

** Giới hạn quyền truy cập vào các máy cụ thể **

Theo mặc định, tất cả người dùng trên máy chủ SSH của chúng tôi sẽ có thể truy cập tất cả các máy.Tuy nhiên, chúng ta có thể sử dụng tệp `sshd_config` để giới hạn quyền truy cập vào các máy cụ thể.Để làm điều này, chúng ta cần thêm dòng sau vào Chỉ thị `allusers`:

`` `
Allowusers Bob@Machine1 Bob@Machine2
`` `

Điều này sẽ cho phép người dùng `bob` truy cập các máy` machine1` và `machine2`.

**Phần kết luận**

Trong bài học này, chúng tôi đã học cách tạo và quản lý người dùng và cách giới hạn quyền truy cập vào các máy cụ thể trên máy chủ SSH của chúng tôi.Trong bài học tiếp theo, chúng ta sẽ học cách tạo và quản lý các khóa SSH.

### Người giới thiệu

* [Hướng dẫn SSH] (https://www.digitalocean.com/community/tutorials/how-to-set-up-ssh-seys-on-upuntu-20-04)
* [Cấu hình SSHD] (https://www.ssh.com/ssh/docs/openssh-8.2/sshd_config.html)
=======================================
### [Programming class] Lesson 3: Project ssh all in one - Part 1

**Hashtags:** #SSH #Programming #Tutorial #linux #NetWorking

**Introduction**

In this lesson, we will continue our project of creating a single SSH server that can be used to access multiple machines. In the previous lesson, we created a basic SSH server and configured it to allow users to log in using their SSH keys. In this lesson, we will add additional features to our SSH server, such as the ability to create and manage users, and the ability to limit access to specific machines.

**Creating and Managing Users**

The first thing we need to do is create some users for our SSH server. To do this, we can use the `useradd` command. The following command will create a user named `bob` with a password of `password`:

```
useradd bob
passwd bob
```

Once we have created a user, we can use the `usermod` command to change their password, home directory, or other settings. For example, the following command will change the password for the user `bob` to `newpassword`:

```
usermod -p newpassword bob
```

We can also use the `userdel` command to delete a user. The following command will delete the user `bob`:

```
userdel bob
```

**Limiting Access to Specific Machines**

By default, all users on our SSH server will be able to access all machines. However, we can use the `sshd_config` file to limit access to specific machines. To do this, we need to add the following line to the `AllowUsers` directive:

```
AllowUsers bob@machine1 bob@machine2
```

This will allow the user `bob` to access the machines `machine1` and `machine2`.

**Conclusion**

In this lesson, we learned how to create and manage users, and how to limit access to specific machines on our SSH server. In the next lesson, we will learn how to create and manage SSH keys.

### References

* [SSH Tutorial](https://www.digitalocean.com/community/tutorials/how-to-set-up-ssh-keys-on-ubuntu-20-04)
* [SSHd Configuration](https://www.ssh.com/ssh/docs/openssh-8.2/sshd_config.html)
 
Join ToolsKiemTrieuDoGroup
Back
Top
AdBlock Detected

We get it, advertisements are annoying!

Sure, ad-blocking software does a great job at blocking ads, but it also blocks useful features of our website. For the best site experience please disable your AdBlocker.

I've Disabled AdBlock