Unable to connect to SSH server from MacOS

2,246

Assuming you are using the default NAT network adapter (which works well for most use cases), in order to connect to your virtual machine from your host machine, you will first need to set up port forwarding. In the VirtualBox GUI, bring up the VM settings, then go to Network > Advanced > Port Forwarding. Choose "22" for the guest port and an arbitrary port number for the host port (I like to use "2222"). Press "OK" to exit out of all of the dialogs and apply the settings.

Now you will be able to connect to your VM at the chosen port on your local system. Make sure to use "localhost" or 127.0.0.1 as the hostname. For instance:

sssh user@localhost -p 2222
Share:
2,246

Related videos on Youtube

Nayef
Author by

Nayef

Updated on September 18, 2022

Comments

  • Nayef
    Nayef over 1 year

    I want to move a computer object to another OU I am connected to another domain and I always getting an exception of type ComException "A referral was returned from the server" and the object never move!

            try
            {
                //I get the exception here
                computerObject.MoveTo(new DirectoryEntry("LDAP://OU=someOU,OU=parentOU,DC=test,DC=com"));
                computerObject.CommitChanges();
            }
            catch (InvalidOperationException inOp)
            {
                //log 
            }
            catch (COMException comEx)
            {
                //log 
            }
    
            //joinPath.Close();
            finally
            {
                computerObject.Close();
            }
    

    for troubleshooting I changed the code a little bit but again it doesn't work.

    computerObject.MoveTo(new DirectoryEntry("LDAP://OU=someOU,OU=parentOU,DC=test,DC=com"),
                          "[email protected]","somepassowrd",AuthenticationTypes.Secure));
    

    the new exception is of type ComException "Logon failure: unknown user name or bad password." I checked that there exists an OU in the active directory and I have enough permissions.

    I followed Microsoft docs here https://msdn.microsoft.com/en-us/library/ms180856(v=vs.90).aspx and many stackoverflow questions.

    Update: I am running my application in one domain and making changes in another domain, it might be the cause of the problem

    • rene
      rene over 8 years
      Can you connect to that ldap server with the IP address instead of the name. codeproject.com/Articles/18102/…
    • Nayef
      Nayef over 8 years
      @rene I am connected to the ldap server and I am able to search for objects and show them, but when I want to move it, the exception is thrown. I read the article in code project but I could not solve the problem.
    • lese
      lese over 7 years
      Just guessing - Could it be a Virtual Networking problem? Can you ping <vm_ipaddress> from HOST ?
    • Vishera
      Vishera over 7 years
      I have able to ping everything. Tried with: google.com, 8.8.8.8, localhost, x.x.x.x (the ip address displayed after bash command <hostname -I>
    • Vishera
      Vishera over 7 years
      In the HOST /etc/ssh/ssh_config there is nothing strange, I suppose. I have configured it and tried different variations. Right now it's all default, nothing modified after a purge and reinstall of the SSH service. I'm sort of new into this, so could you let me know, what I shall modify, if there is anything?
  • Vishera
    Vishera over 7 years
    I have tried that as well, i have also tried with 2 NAT's tried to configure it in any means possible. The only solution which worked, was the one with port forwarding and connecting with localhost. to the port of the VM.
  • jayhendren
    jayhendren over 7 years
    @Vishera that's because VirtualBox creates a virtual private network for the VMs. The IP that gets assigned to the VM only is routable from within that network, which is why you can't use that IP to ssh to your VM - your host OS isn't on that virtual network.
  • Vishera
    Vishera over 7 years
    And that means, that if I want to host a service or website or anything on a VM Virtual machine and access it from outside the private network, I won't be able to do that with VM? Or even if I want to access this very VM machine from another computer?
  • jayhendren
    jayhendren over 7 years
    You can do that with port forwarding or with bridged networking (there are other solutions as well). For instance, if you have a vm "X" running a website, and X is hosted on host "A", and you forward port 80 on X to 8080 on A, you can browse the website from a different host "B" by going to http://A:8080 in your web browser on B.
  • Vishera
    Vishera over 7 years
    that sounds highly plausible. I'm new to Virtualization and I appreciate your help