How to get own vm name in guest environment - virtual-machine

I want to change VM setting in my own guest VM.
I can connect to vCenter but I'm not detecting my own VM.
What is a simple way to get the VM name?

Pretty sure you can use a simple Powershell command like so:
get-vmmserver localhost | get-vm "vmname" | select Name, ComputerName,
HostName | format-list

PowerCLI allows you to do this simply with:
Connect-VIServer -Server vcenterservername.fqdn
Get-VM -Name vmname
You can also just connect to the web client and perform a search at: https://vcenterservername.fqdn/

Related

using google gcloud to ssh tunnel into linux machine inside network

I have an Ubuntu 16.04 VirtualBox machine (i.e. machine A) running on OSX connected to a university campus network. I would like to occasionally ssh into the machine from my laptop to remotely assist my colleagues, and I looked at different options.
It seems one of the options is "reverse ssh" (related to "port forwarding" or "ssh tunnelling"). My laptop does not have a fixed IP, so I can't do straight reverse ssh. The possible solution is to use a proxy machine. The idea is that when I need to assist my colleagues, they will type in the connection instructions from machine A, this will create a running GCP instance, and I will be able to then connect to machine A from the outside using this bridging (proxy?) GCP machine.
/ Academic intranet
+----------+ |
| GCE | | +----------+
| instance |<----|--| Machine A|
+----------+ | +----------+
|
\
/ Academic intranet
+----------+ |
+-------------+ ssh | GCE | ssh | +----------+
| Laptop dynIP|---------->| instance |-----|->| Machine A|
+-------------+ +----------+ | +----------+
|
\
We have a Google cloud account and gcloud installed on machine A. For what I can tell, GCP already has a very simple way to set up a tunnel in GCP:
https://cloud.google.com/community/tutorials/ssh-tunnel-on-gce
I tried it and it works. Which makes me guess that the same should be possible on GCP for the final step: for me to be able to open an SSH browser window on the running GCP instance so that I can ssh into machine A from there.
Any ideas?
EDITED:
Here is how far I got following the ssh tunnel on gce instructions:
On machine A:
gcloud compute instances create --zone us-west1-a tunnel
gcloud compute ssh --zone us-west1-a tunnel -- -N -p 22 -D localhost:2210
On my laptop, I can open https://console.cloud.google.com/compute/instances and then open a browser window to SSH connect.
From the GCP instance hostname tunnel, I guess I am missing something like:
ssh-into-machine-A-from-here
This is the last command that I am missing. Or maybe the ssh tunnel in gcloud needs extra flags/parameters.
0) Create an instance on GCP with a command like:
gcloud compute instances create --zone us-west1-a tunnel
0b) Click on the 'SSH' link on https://console.cloud.google.com/compute/instances to open a browser window.
0c) On the browser window, edit the sshd_config file to enable GatewayPorts yes.
0d) Set up gcloud CLI and connect the first time as shown below:
gcloud compute ssh --zone us-west1-a tunnel
This will create the ssh keys in $HOME/.ssh/google_compute_engine. Disconnect from it. Now that the keys are created, follow the next steps.
1) To establish forwarding from GCE to machine A: run following on machine A:
ssh -i ~/.ssh/google_compute_engine -o UserKnownHostsFile=/dev/null -o CheckHostIP=no -o StrictHostKeyChecking=no -f -N -R 2022:*:22 gce_user#gce_address
2) Now, to connect to machine A from your laptop, you can use the browser window with the GCP instance and do:
ssh -p 2022 A_machine_user#localhost
This should then ask for the password on A_machine_user and connect you to machine A.
I am not 100% sure that I got your exact question, but as far as I understood creating a VPN should be the best solution for you. The best and safest way of connecting your GCE instance with the machine A.
You can find here a discussion on the same kind of implementation.
Another option, which is in the same spirit is to a Virtual private server like OpenSSH on Machine A. Here there is a guide on how to implement that using a Virtual Private Server like OpenSSH and how to configure it.

Get VM Name and FQDN

Im trying to write a Powershell Query to get the VM Name & FQDM, this is what I have but its not returning the FQDN
Get-AzureRmVm | Select-Object Name , #{Name="FullyQualifiedDomainName"; Expression={$_.ToPSVirtualMachine().FullyQualifiedDomainName.Value}} | Format-Table
Update 1
So I have been able to get the VM, and then the FQDN, and I feel its safe enough for me to do it this was because i know a single RSG will only even contain one VM and one FQDN, so its safe for me to assume they are linked.
Get-AzureRmVm | Foreach-Object{Get-AzureRmPublicIpAddress -ResourceGroupName $_.ResourceGroupName} | Select-Object ResourceGroupName, Name , Location , #{Name="FQDN"; Expression={$_.DnsSettings.Fqdn}}
However it is slow because of the Foreach, wondered if anyone has any other suggestions on this.
When you create an Azure VM, a public IP resource for the VM is automatically created. Refer to this. None of FQDN is created for a VM in the Azure portal. You could configure it once the VM is created. You could not get the FQDN directly by using the AzureRM.Compute module since the FQDN or DNS name is not a property of VM but is a public IP address configuration.
You can get an FQDN of an Azure VM using
(Get-AzureRmPublicIpAddress -ResourceGroupName $rg -Name $publicipaddress ).DnsSettings.Fqdn

Creating a SSH tunnel passing through a 'bridge' machine

I need to access from a PHP script a database hosted on another machine which is accessible only via SSH using a bridge machine.
How can I setup a tunnel so that I can tunnel the connection from my machine to the database passing through the 'bridge' machine?
It is actually quite simple. It is just a matter of a single command:
ssh -N -L localhost:3306:DATABASE_MACHINE:3306 BRIDGE_MACHINE_USER#BRIDGE_MACHINE
You should use ssh -L option to do this
You can read this: http://www.revsys.com/writings/quicktips/ssh-tunnel.html

Glassfish asadmin to list running applications' ports

I'm using Glassfish 3+ and deploying the applications to application server. My glassfish instance's port not "8080". when i enter the Glassfish Admin Console and going to Running Applications , i can see the port number which works. For example : 43888. How i can see the port numbers running applications on command prompt? Which asadmin command with?
The quick and dirty way is to use the following command (on UNIX/Linux):
asadmin get '*' | egrep -i '[._]port[=.][1-9v]' | sort
This gets you most all the port values that are being used in a domain.

Lamp configuration on CentOS

I have installed LAMP on my CentOS server VM, where I want to access my server by the browser of my local machine, but it doesn't work. Please help me find the solution.
Are you sure it's running?
try
ps ax | grep httpd | grep -v grep
and if you see no output do:
/etc/init.d/httpd restart
The server will be accessible on your configured virtual host. Make sure you follow each step in this guide.
Is your VM network bridged or NAT'ted? If bridged, something on the VM is wrong as it should just show as a standard machine on your network. If NAT'ted, you will need to read up on NAT connections in your virtualisation documenation.