systemctl start sshd
systemctl enable sshd
systemctl stop firewalld
systemctl disable firewalld
設定 → 網路 → 進階 → 連接埠轉發:
| 名稱 | 協定 | 主機 IP | 主機連接埠 | 客體 IP | 客體連接埠 |
|---|---|---|---|---|---|
| SSH | TCP | 127.0.0.1 | 2222 | 10.0.2.15 | 22 |
| Tomcat | TCP | 127.0.0.1 | 8080 | 10.0.2.15 | 8080 |
| ActiveMQ | TCP | 127.0.0.1 | 61616 | 10.0.2.15 | 61616 |
| ActiveMQ Web | TCP | 127.0.0.1 | 8161 | 10.0.2.15 | 8161 |
主機瀏覽器/Xshell 連線 127.0.0.1:2222 即可進入虛擬機。
ip addr show eth0 | grep inet
/opt/app/service.sh:#!/bin/bash
export JAVA_HOME=/opt/app/jdk1.8.0_121
sh /opt/app/apache-activemq-5.14.4/bin/activemq start >/opt/app/start.log
chmod +x /opt/app/service.shchmod +x /etc/rc.d/rc.local (CentOS 7 預設無執行權限)/etc/rc.d/rc.local 末尾加入 /opt/app/service.shVirtualBox 管理介面選擇「無頭模式啟動」,背景運行,主機透過 SSH/Xshell 全天候操作。