how can I connect to the display on a google cloud machine? - ssh

I have succesfully created a machine on Google Cloud which I can access via
gcloud compute ssh my-service
however passing -X to ssh is not an option and I would like to see some plots.

Not sure what you mean with:
however passing -X to ssh is not an option and I would like to see some plots.
But you can also use the google console to connect to the SSH and get system usage graphs like CPU, Memory, Disk and Network usage.

Linux instances on GCP are server versions of the OS. There is no desktop. You can try using a VNC viewer like TigerVNC to get a similar desktop interface. You can also RDP to a windows instance to get a windows desktop. Your question is unclear. You will need to be more specific as to what you mean by "plots", "connect to the display", "-X" these terms are all very general and specific to your personal environment wherever you were.

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.

Gcloud compute SSH connects to a different Instance than SSH + certificate

So I'm trying to connect to a gcloud instance where I've installed several packages and started to develop my code with no problem. During the week, I use a certificate and putty to login since I work with a windows machine.
However now that I'm home, I tried to connect to the instance using my mac where I installed the Google Cloud SDK and after configuring all the parameters using
gcloud init
I get logged to an empty instance that doesn't have all of the packages and scripts I mentioned above.
What am I doing wrong? I can confirm that I'm connecting to an instance with the same name, in the same region and all, but it is completely different.
Cheers!
As you are connecting from a different machine, that's a different user.
Go to /home, and check if there is a folder with the "other" username. Note that you might not be able to access. You would need to become superuser.

Using saltstack ssh

Is there a difference between using salt-proxy ssh and directly salt-ssh? I'm interested because according to documentation both aimed to run remote commands without agent installation on the end machine.
You cant simply do salt-ssh on a proxy minion, for which you would have to write your own custom ssh interface to the remote system, because your proxy minion may not support doing salt-ssh.
How to choose between using salt-ssh vs salt-proxy totally depends on the type of a minion system.
As stated in the saltstack documentation - https://docs.saltstack.com/en/latest/topics/ssh/index.html and
https://docs.saltstack.com/en/latest/topics/proxyminion/index.html
For salt-ssh to be used, the remote system must have python installed - one of the criteria. For example, controlling ubuntu from centos.
As stated in the salt-proxy doc,
Proxy minions are a developing Salt feature that enables controlling
devices that, for whatever reason, cannot run a standard salt-minion.
Examples include network gear that has an API but runs a proprietary
OS, devices with limited CPU or memory, or devices that could run a
minion, but for security reasons, will not.

Not able to SSH into google compute engine server from developer console

I have a linux machine on google compute engine.I am not able to SSH into instance from developer console. I added SHH keys, still I cant access it through WinSCP. I was able to access it few days back. What is the problem and how can I solve it ? It is showing following message.

What API can be used to change windows account information remotely?

What API is available to change windows account passwords remotely? Assuming I have the proper credentials to change the windows accounts, I need to write software that can do so remotely.
The software will run on Linux, and so far it appears that SMB may have some functionality in this area, but I need either an API, library, code, or even the right key words to help me figure out how to search for solutions or an approach to solving this problem.
I've found Wmi client on Linux but as far as I understand there seems to be issues with it.
Try:
smbpasswd -r machine -U user.
You can use wmi-client, but on the other hand that does not work on windows 2008 server with domain controller and the password is passed in the network without encryption.
The smbpasswd command that is part of Samba allows you to change the password on remote machines. E.g.
smbpasswd -r MACHINE -U USER
You should be able to just invoke that command from your favorite programming language; the next version of Samba will have some Python APIs that probably also allow you to do this from within Python.