How can I ping/ssh to my VM from the host only (shared networking mode)?

Discussion in 'General Questions' started by XavierN1, Feb 9, 2022.

  1. XavierN1

    XavierN1 Bit poster

    Messages:
    5
    Hello,
    [Parallels Desktop 17.1.0 (51516) on macOS Monterey 12.0.1, with various VMs including Ubuntu 18 and 20]

    I would like to be able to ping my VMs (or ssh to them) from the host. Yet, I want to keep the shared networking mode because it hides the VMs from outside the host (and therefore simplifies security of these VMs tremendously). How can I do this?

    I verified that the various VMs I have can ping each other (so it's not a firewall issue), that they have internet access, and that they can access the folders shared from the host. Basically, everything is working as it should. When I ping the VM (with its IP address) from the host, I get timeouts. I understand that this is expected in shared mode, but I would expect that I can manually add a route on my host OS to the virtual subnet created by Parallels. Or that I can configure Parallels' virtual router to allow the traffic, whichever is relevant...

    How can I achieve that?
    Thanks!
     
  2. GlennH2

    GlennH2 Bit poster

    Messages:
    2
    I would like to know how to ssh into a Ubuntu 22 VM from my Mac host, as well. VM is using default shared networking.
     
  3. GlennH2

    GlennH2 Bit poster

    Messages:
    2
    My setup is newer than your, but it may be helpful anyway.
    Parallels Desktop 18.3.1 (53614) (M1, arm) on macOS Monterey (12.6.6) with Ubuntu Server 22 LTS using default shared networking.

    During the Ubuntu installation I opted to allow ssh via password, but that's the default in /etc/ssh/sshd_config anyway.

    From terminal on VM to see the IP to use:
    networkctl list

    This showed 2 links for me. The second one was the one with DHCP
    networkctl status 2
    (or alternatively)
    networkctl status enp0s5

    This shows the assigned address from DHCP. Mine was 10.211.55.23

    Then I was able to login from the host with my user/password: ssh username@10.211.55.23

    After than I used rsync to get my ssh public key on the VM and copied it into ~/.ssh/authroiized_keys.
    That's all it took. I don't know if the DHCP will assign the same IP every time (I think it does by MAC address), but it's easy enough to discover now.

    After you know the IP for your VM, you can add it to /etc/hosts on you Mac to access the VM by name.

    Hope it helps you.
     

Share This Page