Skip to main content

Command Palette

Search for a command to run...

SSH into Boxes VM from Host

Published
1 min read

In guest VM (Ubuntu)

# Optional, tmux is convinient for long running task
sudo apt install tmux 

# Start a tmux session
tmux

# Creates a reverse SSH tunnel from the host (_gateway) 
# back to your VM, mapping the host port 2222 to VM port 22, 
# allowing SSH access to VM through the gateway. 
# Need to change host_user_name 
ssh -NT -R 2222:localhost:22 host_user_name@_gateway

# Detach tmux session
# Ctrl+b then d

# Optional, to bring tmux session back 
tmux attach
# or list session and bring session with certain ID
tmux ls
# 0 is the session id from previous output
tmux a -t 0

In host

# Need to change guest_user_name
ssh -p 2222 guest_user_name@localhost

Reference

https://unix.stackexchange.com/questions/627187/ssh-into-gnome-boxes-os