jvisualvm for remote host - jvisualvm

I want to use jvisualvm's remote functionality to see live stats of a remote JVM.
I've started the jvisualvm from my windows machine but I don't know how to configure the remote connection.
On the remote machine (OS: Redhat Linux), tomcat is started with below jmx parameters:
-Dcom.sun.management.jmxremote"
-Dcom.sun.management.jmxremote.port=3030"
-Dcom.sun.management.jmxremote.authenticate=false"
-Dcom.sun.management.jmxremote.ssl=false"
netstat -lnp| grep 3030
tcp 0 0 0.0.0.0:3030 0.0.0.0:* LISTEN 30728/java
ssh connection is open to remote server and I tunneled the remote port 3030 on a certain local port but when I create new jmx connection (localhost:localport) in jvisualvm I get the below error
Cannot connect to localhost:10000 using service:jmx:rmi:///jndi/rmi://localhost:10000/jmxrmi
Can someone help me to create the connection?

First of all if you are making a remote connection, localhost connection doesn't make sense.
You need to start jstatd on the remote machine. For this purpose create a jstatd.all.policy file in the home directory of your remote machine and add the following lines:
grant codebase "file:${java.home}/../lib/tools.jar" {
permission java.security.AllPermission;
};
Then on the command line of your remote machine you will type ' jstatd -J-Djava.security.policy=jstatd.all.policy -J-Djava.rmi.server.hostname={Your Ip address} '
Once jstatd service start on the remote machine you basically add the remote connection Ip address connection on the jvisualVM UI using add remote host.
The Oracle documents for JvisualVM can be referred at https://docs.oracle.com/javase/8/docs/technotes/guides/visualvm/applications_remote.html but it is really confusing to understand jstatd steps.

Related

Connect host ldap server to local VM

I have a server installed on VM and a LDAP(opendj) server created using Apache Directory Studio on my host computer. Now, I would like to connect that LDAP server to local VM so that the VM server can pull user's information from LDAP server. is it possible to do that? I could not understand how to establish a communication between these two server.
Thanks.
Remote Port Forwarding actually does work here.
my ldap server port was 10389.
I have created a tunnel from host to vm:
ssh -R 10389:localhost:10389 root#172.16.130.132(vm-ip)
after then, vm can reach to the host through this port (10389).
Sorry, I don't have that much knowledge on ssh. But this one worked for me.

How to connect to OCI machine if the sshd is not responding?

I was updating the ssh port of an Oracle Cloud Infrastructure machine
I changed /etc/ssh/sshd_config
The port was
#Port 22
I changed it to
Port 40531
Then
restarted the sshd service systemctl restart sshd
open the port on the OCI Web
however, now I cannot connect.
ssh -vvv -p 40531 -i ~/.ssh/vm.key opc#129.xxx.xxx.xxx
OpenSSH_8.2p1, OpenSSL 1.1.1e 17 Mar 2020
debug1: Reading configuration data /etc/ssh/ssh_config
debug2: resolve_canonicalize: hostname 129.xxx.xxx.xxx is address
debug2: ssh_connect_direct
debug1: Connecting to 129.xxx.xxx.xxx [129.xxx.xxx.xxx] port 40531.
debug1: connect to address 129.xxx.xxx.xxx port 40531: Connection timed out
ssh: connect to host 129.xxx.xxx.xxx port 40531: Connection timed out
I saw a Cloud Shell but I'm not sure if it can be used to connect to the machine to perform maintenance tasks
Is there a way to connect to the VM from the web oci interface to fix the ssh issues?
I used to use a VPS service that has a web console from which you can enter to fix problems like this
is there something like this in OCI?
Note:
SELinux was disabled on the machine
if you are about to do this on your machine, remember to update the SELinux configuration prior restart the sshd service or you will be locked out, another option is to disable SELinux totally (this is what I did)
The changes above described worked well, the only thing that was causing issues on my side
(I don't really know why) is that I was connected from a VPN
After I disconnected the VPN and tried to connected again it worked
Update:
I figured out why the ssh using a different port was not working. The VPN I use is a corporate VPN which has very strict inbound and outbound rules, The VPN outbound rules were blocked by the TCP on port 40xxx.
Update:
if you are struggling with a VM you can connect using the below instruction
Creating the Instance Console Connection
Before you can connect to the serial console or VNC console, you need to create the instance console connection.
To create the console connection for an instance
Open the navigation menu. Under Core Infrastructure, go to Compute and click Instances.
Click the instance that you're interested in.
Under Resources, click Console Connection.
Click Create Console Connection.
Upload the public key (.pub) portion for the SSH key. You can browse to a public key file on your computer or paste your public key into the text box.
Click Create Console Connection.
When the console connection has been created and is available, the state changes to Active.
Thanks to #bmuthuv for the info
You can connect to Serial Console of the VM where you could get access to GRUB Menu during a Reboot operation. You can subsequently use typical Linux commands to get to Shell from Grub. You can subsequently undo anything you would like to.
Serial Console connection can be created on OCI Web Console in the Instance's page.

How to fix ngrok forwarding port?

I am ssh-ing onto a remote desktop. Since I have to connect over the internet, I have exposed the ssh port (22) on the remote side using ngrok, and everything is working great. I connect to the desktop using the command
ssh username#2.tcp.ngrok.io -p portno
where I get the portno from the remote side, when I start the ngrok service from the line that says
Forwarding tcp://2.tcp.ngrok.io:portno -> localhost:22
However, everytime I start a new ngrok session on the remote side, a new portno is generated. Now, unless I have a secondary connection open (typically using teamviewer), I would not be able to know what that port number is.
How can I start the ngrok service with a fixed portno. This is because I want to have the ngrok service on startup as I would have to restart my remote desktop a couple of times and still want to connect to the desktop using ssh.
Thanks.
You'll need to reserve a TCP address on ngrok, which will give you a fixed address.
To associate a tunnel with a reserved TCP address, you should include the remote-addr option in your ngrok config when starting the tunnel.
An example from the docs: ngrok tcp --region=us --remote-addr 1.tcp.ngrok.io:20301 22

What's the best way to reverse ssh tunnel to access system behind corp firewall?

I am trying to access a linux server through ssh. Typically this is accessed through a Win2012 jump server using putty.
I was able to setup a reverse ssh connection in putty from jump server to a AWS VM through HTTP proxy. And this was supposed to forward it to my linux server. But when I connect to my AWS VM and initiate ssh over my remote port, the whole thing just hangs. What am I doing wrong, and is there a better/easier way? No malicious intent, I have physical access to both jump server and linux server. Just bypassing shitty corp firewall.
Can you explain what you did in details ?
Typically on unix systems, for a reverse ssh tunnel, you can do this on your server behind the firewall:
ssh -NR ssh_port_AWS:localhost:ssh_port_local_server user#ip_AWS
You need to replace
ssh_port_AWS by the port of the distant server that you want to use to access the local server.
ssh_port_local_server by the port of the ssh server of your local server (if you don't change anything, 22).
user#ip_AWS by your AWS connection details (user#IP)

how to define a tunnel connection to remote desktop in putty?

I need to connect (in rdp ) to a machine (let's call it #1) in my college network ( I have the internal IP of it ) , I also have access the to Linux server machine in the same network in ssh , that I can use to access the #1 ,
I'm using putty, can someone please explain to me how I can connect to it ?
[My laptop] --->[Linux server] --->[windows machine] in rdp
Thank you,
Let's assume the following:
Linux Server - gate.college-server.com:22 (SSH listens on port 22)
Internal Server - internal.college-server.com:3389 (RDP listens on port 3389)
RDP connection will be on localhost:3399 (the port should be opened)
How to configure the SSH tunnel via Putty with RDP forwarding:
Open Putty and in the Session enter the connection info for the Linux Server
Go to branch > Connection > SSH > Tunnels
Choose Local and Auto
in the Source Port enter 3399, and in the Destination - the connection info of the internal machine in the format: hostname:port.
Click Add
you will see entry in the Forwarded ports section, something like:
4L3399 internal.college-server.com:3389
Save your connection and it's ready to use.
Next, start the a PuTTy Session with the Saved Connection and after you login successfully
to the remote server gate.college-server.com:22, you can start your Windows RDP client.
Connect with it to localhost:3399 and use the RDP credentials for internal.college-server.com:3389