Remote interaction via VNC+Expect? - automation

I've being doing a installation process in several machines in virtualbox and I'd like to try automated this process. I can do a expect script (see below), however I can't connect through ssh because this script will configure the network stuff after some other processes.
Where I work now, we use the vmware esxi and I am trying to discover if it's possible to automated the installation process that I said if I setup the vnc viewer in the guest machine. I can do the all process if I do it manually, but I'd like try to automated it. Although I think a expect script will be fine, I'm not connecting by ssh. Is it possible?? I started to think that maybe expect is not my answer here.
The processes is something like this:
Receives "Choose a option: ", sends "1\n"
Receives "Press any key", sends "\n"
Repeat step 2 more two times.
Receives "Do you agree (y/n)?", sends "y\n"
And so on.
The host as I said is a vmware esxi, the guest is similar to a linux and my machine is a fedora 20 (I'm saying this because I dont like the idea of install stuff on esxi).

Related

Can I run one WSL2 virtual machine instance on two system?

I'm new to the WSL2 and wondering if it's possible to run the same WSL2 ubuntu instance on both my desktop and laptop.
Now I am able to use wsl --export and wsl --import method to save and load the system to/from my portable hard drive. But these methods takes a long time.
I notice that wsl --import load a file named ext4.vhdx. Is there a way to load straightly from this file?
Update v2.0:
I was able to get a workaround and it works great.
Thanks to Booting from vhdx here, I was able to load straightly from my vhdx file on my portable hard disk. Windows track down its subsystem with regedit, So we can write our own(p.s: make sure to get BasePath right, it starts with "\\\\?", or you will not be able to access the subsystem' filesystem on your host system.):
Windows Registry Editor Version 5.00
[HKEY_USERS\【your SID here】\SOFTWARE\Microsoft\Windows\CurrentVersion\Lxss\{【UUID here】}]
"State"=dword:00000001
"DistributionName"="distribution name"
"Version"=dword:00000002
"BasePath"="vhdx folder path" 【 e.g. "\\\\?\\E:\\S061\\WSL\\ubuntu-20"】
"Flags"=dword:0000000f
"DefaultUid"=dword:000003e8
I suppose the best way to do this would be to store ext4.vhd on a network storage device accessible to both devices.
I have previosly mentioned how to move ext4.vhd. You can check that out here
Basically you need to export from one machine and import it while making sure the vhd file is configured for wsl to access from the network storage
Since this should *officially* not supported expect some performance hits
Another way would be to run WSL on one computer and ssh/remote desktop to it from another device on the network
I'm of the strong belief that sharing the same ext4 vhd between two VM's simultaneously would be a bad idea. See this and this Unix & Linux StackExchange, including the part about ...
note that sharing LVs/partitions on a single disk between the servers at the same time is NOT very safe. You should only access whole disks from any of the servers at one time.
However, as dopewind's answer mentioned, you can access the WSL instance on one computer (probably the desktop) from another (e.g. the laptop). There are several techniques you can use:
If you have Windows 10 Professional or Enterprise on one of the computers, you can enable Remote Desktop, which allows you to access pretty much everything on one computer from another. RDP ("Remote Desktop Protocol") even works from other devices such as an iPad or Android tablet (or even a phone, although that's a bit of a small screen for a "desktop"). That said, there are better, more idiomatic solutions for WSL ...
You could enable SSH server on the Windows 10 computer with the WSL instance (instructions). This may sound counterintuitive to some people, since Linux itself running in the WSL instance also includes an SSH server (by default). But by SSH'ing from (for example) your laptop into your desktop's Windows 10, you can then launch any WSL instance you have installed (if you choose to install more than one) via wsl -d <distroName>. You also avoid a lot of the network unpleasantness in the next option ...
You could, as mentioned above, enable SSH on the WSL instance (usually something like sudo service ssh start) and then ssh directly into it. However, note that WSL2 instances are NAT'd, so there's a whole lot more hackery that you have to do to get access to the network interface. There's a whole huge thread on the WSL Github about it. Personally, I'd recommend the "Windows SSH Server" option mentioned about to start out with, then you can worry about direct SSH access later if you need it.
Side note: Even though I have SSH enabled on my WSL instances, I still use Windows SSH to proxy to them, to avoid these networking issues.

Pycharm cannot finish updating skeletons

I'm newly moving from a Linux working environment to Windows, and I'm mainly using local port forwarding+Pycharm to run my python code on a server that is double-hop from my laptop.
I am able to establish the ssh tunnel through Windows cmd or MobaXterm local terminal or MobaXterm tunneling tool. I works fine on my Pycharm, when I check it from tools/deployment/configuration/test connection, and I can also see the files in remote server. But every time I start my Pycharm, it shows two background process, "updating python interpreter" and "updating pycharm helper", and the precess bar simply do not show any moving on! And I cannot run python on remote server, because Pycharm says I lack python helper.
And most wired, when it is running these two precess, my terminal for local port forwarding freezes, and I cannot type in commands in the jump server. And when I try to recheck the connection, it turns out that connection fails.
My ssh tunneling+pycharm deployment used to work fine in my Ubuntu. Thanks anybody who can shed light on my confusion!
Well, thanks everyone, I have solved this problem.
The reason is simple, but I did not notice that the ~/.pycharm_helper 's size is actually changing in the process, while the GUI bar may be not moving.
So it is due to my double-hop inconvenience, and the low Internet speed. I left it in dorm for a whole night out, and it comes out just fine.

monitor local file excution/access history triggered by a remote server

My question is somewhat similar to this, but a little different from that:
I want to monitor the file execution/access history on a CentOS 7.2 machine. I know that a remote server is calling some files on my local machine through SSH in order to finish some tasks, so I want to find out what files on my local machine that the server is calling.
I tried to use the terminal command:
ls -lu
but it didn't show any invocation history that was triggered by the remote server through SSH. Later I learned about inotify. But I also heard that it's not available on Centos 7. Is it true? If not, how should I use it? I didn't find a dirty and quick inotify tutorial for centos. Is there any system logs that records this type of information? Any other ideas on how to achieve my goal?

Get access to specific terminal emulator over SSH

background:
I use a linux box(call it host) everyday. But sometimes, the GUI/mouse/keyboard stop working and it(host) hangs. I was not able to do anything but restart it(host). So, now i always a ssh server running on it(host) so that I can connect to it and turn off things safely. I do this by using VNC client on my laptop(call it REMOTE). It replicates the whole screen from the host, so even if my mouse/keyboard on the host don't work, i could close things with REMOTE. But VNC is expensive on network usage and slow. I want to replace it with normal ssh connection.
problem redefined:
So, if I start a simple program to print "hello world" endlessly on terminal on the "host". How can i see the same terminal(with hello world printing) on "REMOTE" over SSH. Not just see, control this program say stop it, kill it etc.

run gnu-screen/tmux/byobu from client

I need to understand a fundamental concept about terminal multiplexers yet I can't seem to find the answer.
As I understand these programs need to be installed on server but not necessarily on clients. It's not a problem with gnu-screen as it is already installed on most systems but it's not the case for tmux and byobu. The problem is that I don't have permission to install software on the server. Is there a way I can run byobu from my client to show statistics about the server I connect?
Also what exactly is the effect of 'byobu-enable' option?
I think there is a misunderstanding here. When you connect to the server and run a command (byobu in this case), you are running the command on the server. Statistics reported are for the server. It's possible to open a byobu session on your own desktop of course, but if you're ssh'd into a machine, you're very likely to be executing commands on that machine.
byobu-enable sets byobu to launch automatically when you open a terminal. I don't do this since you can have confusion if you have byobu running locally and on the remote end you have connected to, which causes problems when you try to interact with byobu itself.