cygwin/sshd and Virtualbox - cygwin

I'm using vagrant/VirtualBox on my Window (8.1) Laptop to start up a linux-test-vm from a Cygwin terminal... vagrant up, vagrant ssh, everything is working fine.
Now I want to work on that environment remotely from my main Linux-Workstation, so I've set up sshd in Cygwin and I can successfully ssh into my Windows-Box (same user as logged in locally in windows).
But when I cd'ed (via my remote ssh connection to windows-laptop) in my working directory and ran vagrant ssh, it tells me:
VM must be created before running this command. Run 'vagrant up' first
But I see the VM is running in VirtualBox GUI on Windows.
From this point on even locally on the Windows machine I can no longer interact with the running vagrant vm and the .vagrant (sub)directory has not files inside.
Same happens vice versa:
I stopped/deleted the VM in VirtualBox GUI
ran vagrant up via my ssh connection ... worked
ran vagrant ssh via my ssh connection ... works
but I do not see the VM in VirtualBox GUI on Windows
trying vagrant ssh locally on Windows ... same error again and .vagrant directory gets cleared
So I assume the Cygwin/sshd connection creates some sort of different Sessions that do not share the same "instance" of VirtualBox.
Is there any chance to share VirtualBox/vagrant environment between the local Windows and remote ssh session ???
WORKAROUND:
export ssh-config on the windows host: vagrant ssh-config > ssh_config
from the cygwin/ssh jump into the VM: ssh -F ssh_config default
never run any vagrant command from the cygwin/ssh connection

Vagrant has a built-in solution since the 1.7.x versions called vagrant share which also allows you to remote into a box directly (bypassing the Windows host abstraction). It is generally used for the HTTP feature (eg. to show clients or others on a project the current state of work) but there is the ability to connect to any service running on any port. From the docs:
Just call vagrant share. This will automatically share as many ports
as possible for remote connections. If the Vagrant environment has a
static IP or DNS address, then every port will be available.
Otherwise, Vagrant will only expose forwarded ports on the machine.
Note the share name at the end of calling vagrant share, and give this
to the person who wants to connect to your machine. They simply have
to call vagrant connect NAME. This will give them a static IP they can
use to access your Vagrant environment.
Note to use vagrant share you need a (free) account with hashicorp.

Related

When I use visual studio remote linux to connect to connect to a linux virtual machine, the connection is instability

I use visual studio remote linux to connect to connect to a linux virtual machine(On VMware).
I can always ping virtual machine's host name succesfule.But when I try to test this connection ,somtime it success,sometime it fail.
Got to your remote machine
ps -fux
type above command you will see list of processes
kill the one's running .vscode-se***
and try connecting again it will work
I have solved this problem,but I don't know why.
At the time I find this problem, I connect to virtual machine by it's hostname (getted by linux command hostname).just like this image.
But when I change to connect to virtual machine by it's ip address,this problem is solved.

Connect to Docker on a different machine on a Windows

Related to this but not an (exactly) similar question, how do you run Docker on Windows but the "actual" Docker runs on a different machine.
So it's like, you have a Windows 10 guest VM machine as a development environment with Docker on it, but since it's a guest VM and nested virtualization is still in question, the actual docker "server" runs on a different guest VM (perhaps a Linux server or something)
So the question is:
How to set up a remote Docker?
How do you connect to a remote Docker?
How do you make that as if the remote Docker is running on your local machine, that is, commands work and you can map ports, etc.?

When I run the script on a remote server it starts up on the local machine

I have nautilus-dropbox installed package on my remote server.
I connect to the remote server by ssh, then run command:
dropbox start
And it starts up on my local machine, how it's possible?
Linux systems use the X11 protocol for most GUI systems.
The X11 server renders the image and accepts mouse and keyboard input.
The application acts as a client and connects to whatever X11 server you tell it to. This is done with an environment variable.
When you connect over SSH, a tunnel is created back to your local X11 server, and the shell spawned by SSH has the environment variable set to point along that tunnel to your local display.

Virtualbox- Cant access to VM when running in Headless mode

I installed an ubuntu server with openssh server on a virtualbox and it works fine. when I start it from GUI I can access it via ssh and Putty, there is no problem. When I start it In headless mode from virtualbox gui there is no problem either.
the problem is, when I run it using VBoxManage startvm "Ubuntu" --type headless it returns a message saying that the Ubuntu is running in headless mode but when I want to connect via ssh to it, its not accessable. my host os is windows 10 and the ubuntu server name is "Ubuntu" and os version is ubuntu-16.04.2-server-x64 and I installed openssh-server and dkms as it described here: https://www.htpcbeginner.com/install-virtualbox-guest-additions-on-ubuntu-debian/
when I work in GUI evrything is fine but I want to run it from windows command line to save some time.
It looks like that the command line vm "Ubuntu" is diffrent from GUI vm "Ubuntu". But I have only one vm on virtualbox. in gui there is one and in cmd vboxmanage list vms returns one vm. so what is the problem?
I also added virtualbox guest addition from Device menu in virtualbox GUI
Edit:
I saw another command : VBoxHeadless --startvm "Ubuntu" its not working either. but unlike the last command it does not show message that Ubuntu is Running. actually it will stuck in execution and the cursor turns to a blinking dash for ever. so I should close the cmd to get ride of it.
I checked something. If I use NAT on network adapter and port forwarding, it works even from cmd. but when using bridge to avoid using port forwarding its not working. in the bridge mode there is connection and ping is working but cant ssh to the Ubuntu.
I found the solution. the solution is I should keep the NAT interface as primary as is by default and make a secondary interface in virtualbox gui settings. the secondary interface should be Host-only. then by using this question and its answer I added an interface to guest Ubuntu to a static address. now I can ssh to the static Ip address even if I run the vm from command line, and there is no need to port forwarding.

vim on virtualbox startup is slow when connected via putty

I am running freebsd on virtualbox (with virtualbox-ose-additions installed in freebsd).
the vim startup is very quick (instantaneous) in the vbox console window.
but when connected via putty from the host machine, the vim takes about 6-7 seconds to startup.
the connection from putty is via ssh authentication.
and the host to vbox connection is NAT+portforwarding.
This has happened to me when I had X11 Forwarding turned on in Putty but didn't have an X Server running (always the case when using Putty from (I assume) Windows unless you're running specific software like Cygwin or Xming to have a local X Server).
Alternately, your shell startup scripts may set the DISPLAY environment variable improperly when you're ssh'd in instead of using a console.

Resources