要在Ubuntu虛擬機上進行遠程連接,您可以使用SSH(Secure Shell)進行命令行操作,或者使用VNC(Virtual Network Computing)進行圖形界面操作。以下是具體的設置步驟:
sudo apt update
sudo apt install openssh-server
sudo systemctl status ssh
sudo systemctl start ssh
sudo systemctl enable ssh
/etc/ssh/sshd_config
,例如修改端口或允許root登錄:sudo nano /etc/ssh/sshd_config
sudo systemctl restart ssh
ssh 用戶名@虛擬機IP地址 -p 端口號
ssh john@192.168.0.100 -p 2222
sudo apt update
sudo apt install tightvncserver
vncserver
vncserver :1 -geometry 1920x1080 -depth 24
sudo ufw allow 5901/tcp
請注意,在進行遠程訪問設置時,確保您的虛擬機網絡配置允許外部訪問,并且防火墻設置正確。此外,為了提高安全性,建議使用密鑰認證而不是密碼認證,并定期更新密鑰。