# SSH into Boxes VM from Host

In guest VM (Ubuntu)

```bash
# 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

```bash
# 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](https://unix.stackexchange.com/questions/627187/ssh-into-gnome-boxes-os)
