Posts

Showing posts from March, 2019

Essential SSH commands

The following ssh commands are used by me in everyday development activity. So it prompted me to write a blog post about the essential SSH commands during java development. SSH to a remote server using username and password ssh username@remote-server-host-or-ip SSH to a remote server with a specific port (other than 22) ssh username@remote-server-host-or-ip -p 26 SSH to a remote server using private key (or identity file) ssh -i /path/to/private-key.pem username@remote-server-host-or-ip SSH without host checking ssh -o "StrictHostKeyChecking no" username@remote-server-host-or-ip This avoids the manual confirmation check prompted as given below The authenticity of host '111.222.333.444 (111.222.333.444)' can't be established. RSA key fingerprint is f3:cf:58:ae:71:0b:c8:04:6f:34:a3:b2:e4:1e:0c:8b. Are you sure you want to continue connecting (yes/no)? SSH to a remote server with agent forwarding The following command forwards your SSH auth schem...

Remote JVM monitoring using VisualVM

Image
Most of the modern JVM application frameworks like Spring Boot, Dropwizard and Ktor uses executable jars to bootstrap application with servers embedded inside the jar. The following steps will allow you to monitor the remote JVM running in cloud (or in house data center) using SSH port forwarding and Java JMX. In order to monitor the remote JVM, the java process needs to be started with extra system properties to enable JMX features and you should be able to SSH into the machine where the JVM is running. Start the Java application (or Java Process) with JMX enabled as given below: java -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=10006 -Dcom.sun.management.jmxremote.rmi.port=10006 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.local.only=false -Djava.rmi.server.hostname=localhost -jar spring-boot-application.jar Create a SSH tunnel with port forwarding for JMX port ssh -L 10006...