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
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:
# install prerequisitessudo apt install apt-transport-https ca-certificates git curl software-properties-common gnupg-agent -y# add docker gpg keycurl -fsSL https://download.docker.com/linux/$(awk -F'=' '/^ID=/{ print $NF }' /etc/os-release)/gpg | sudo apt-key add -# add docker software repositorysudo 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 dockersudo apt install docker-ce docker-compose containerd.io -y# enable and start docker servicesudo systemctl enable docker && sudo systemctl start docker# add the current user to the docker groupsudo usermod -aG docker $USER# reauthenticate for the new group membership to take effectsu - $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
- Tạo thư mục dữ liệu, network dùng chung, rồi chạy MongoDB và MeshCentral:
# create working directoriesmkdir ~/docker/meshcentral/{data,user_files} -p && mkdir ~/docker/mongodb -p# set owner of working directoriessudo chown "$USER":"$USER" ~/docker -R# create docker networkdocker network create containers# run mongodb containerdocker run -d --name=mongodb --network containers -v ~/docker/mongodb:/data/db --restart=unless-stopped mongo# run meshcentral container# update the HOSTNAME variabledocker 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 filesed -Ei 's/("NewAccounts": "false",)/"NewAccounts": "false",\n\t"allowedOrigin": true,/' ~/docker/meshcentral/data/config.json# restart the containerdocker 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
- Mở
https://DNSorIP:8086. - Chấp nhận cảnh báo certificate nếu đang dùng certificate mặc định.
- Bấm link tạo account.
- Nhập username, email và password riêng rồi bấm Create Account.
- Đă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
- Tutorial gốc: i12bretro 0963
- Video gốc: Run MeshCentral - Remote Management Site - in Docker
Nguồn
Footnotes
-
https://i12bretro.github.io/tutorials/0963.html — Run MeshCentral - Remote Management Site - in Docker (i12bretro) ↩ ↩2 ↩3 ↩4
Bình Luận & Thảo Luận
Góp ý, hỏi đáp và chia sẻ suy nghĩ của bạn