Bookmark

Chạy MeshCentral để quản trị máy tính từ xa bằng Docker

MeshCentral là web site tự host để quản trị và điều khiển máy tính trong LAN hoặc từ Internet. Bài dưới đây giữ nguyên trình tự i12bretro: một container MongoDB, một container MeshCentral, dữ liệu tách riêng và HTTPS ở cổng 8086.1

Youtube video player

Video gốc cho thấy cùng hướng triển khai; tôi dùng player YouTube nguyên bản, không tải hoặc rehost video.2

Cài Docker trên Linux

Đăng nhập Linux bằng tài khoản có quyền sudo, sau đó chạy nguyên bộ lệnh nguồn:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
# install prerequisites
sudo apt install apt-transport-https ca-certificates git curl software-properties-common gnupg-agent -y
# add docker gpg key
curl -fsSL https://download.docker.com/linux/$(awk -F'=' '/^ID=/{ print $NF }' /etc/os-release)/gpg | sudo apt-key add -
# add docker software repository
sudo add-apt-repository "deb [arch=$(dpkg --print-architecture)] https://download.docker.com/linux/$(awk -F'=' '/^ID=/{ print $NF }' /etc/os-release) $(lsb_release -cs) stable"
# install docker
sudo apt install docker-ce docker-compose containerd.io -y
# enable and start docker service
sudo systemctl enable docker && sudo systemctl start docker
# add the current user to the docker group
sudo usermod -aG docker $USER
# reauthenticate for the new group membership to take effect
su - $USER

Với distro mới, kiểm tra hướng dẫn Docker hiện hành vì apt-key đã deprecated. Đăng nhập lại để group Docker có hiệu lực.1

Chạy MongoDB và MeshCentral

  1. Tạo thư mục dữ liệu, network dùng chung, rồi chạy MongoDB và MeshCentral:
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
# create working directories
mkdir ~/docker/meshcentral/{data,user_files} -p && mkdir ~/docker/mongodb -p
# set owner of working directories
sudo chown "$USER":"$USER" ~/docker -R
# create docker network
docker network create containers
# run mongodb container
docker run -d --name=mongodb --network containers -v ~/docker/mongodb:/data/db --restart=unless-stopped mongo
# run meshcentral container
# update the HOSTNAME variable
docker run -d --name=meshcentral --network containers -p 8086:443 -e HOSTNAME=ubuntuserver.local -e REVERSE_PROXY=false -e IFRAME=false -e ALLOW_NEW_ACCOUNTS=false -e WEBRTC=false -e NODE_ENV=production -v ~/docker/meshcentral/data:/opt/meshcentral/meshcentral-data -v ~/docker/meshcentral/user_files:/opt/meshcentral/meshcentral-files --restart=unless-stopped typhonragewind/meshcentral:mongodb-latest
# update the config file
sed -Ei 's/("NewAccounts": "false",)/"NewAccounts": "false",\n\t"allowedOrigin": true,/' ~/docker/meshcentral/data/config.json
# restart the container
docker restart meshcentral

Thay HOSTNAME=ubuntuserver.local bằng hostname/DNS mà client sẽ truy cập. Không đặt password thật trong command hoặc commit file config.json có credential.1

  1. Mở https://DNSorIP:8086.
  2. Chấp nhận cảnh báo certificate nếu đang dùng certificate mặc định.
  3. Bấm link tạo account.
  4. Nhập username, email và password riêng rồi bấm Create Account.
  5. Đăng nhập và kiểm tra MeshCentral hoạt động.

Kiểm tra và an toàn

Kiểm tra docker ps, log container và volume ~/docker/meshcentral/data trước khi đưa ra Internet. Đặt MeshCentral sau reverse proxy HTTPS có certificate tin cậy nếu dùng bên ngoài LAN; giữ ALLOW_NEW_ACCOUNTS=false sau khi tạo admin và không mở MongoDB ra Internet.1

Nguồn và video

Nguồn


  1. https://i12bretro.github.io/tutorials/0963.html — Run MeshCentral - Remote Management Site - in Docker (i12bretro) ↩︎ ↩︎ ↩︎ ↩︎

  2. https://www.youtube.com/watch?v=V94q02P1zwM — Run MeshCentral - Remote Management Site - in Docker (official video) ↩︎


0 Bình luận

Góp Ý / Bình Luận / Đánh giá