Showing posts with label Putty. Show all posts
Showing posts with label Putty. Show all posts

Sunday, 30 December 2018

AWS - Running a Spring Boot Application on AWS EC2 Instance

This post describes about how you can deploy and run a spring boot application on AWS EC2 instance.

Generate Spring Boot Application 
1. Generate spring boot application from here. Provide Group and Artifact detail and choose Generate Project. Note that this project is generated as a maven project by default . So you must ensure to have Maven in your local machine to build this project.




2. When you choose Generate Project, a zip file is downloaded with name aws-ec2-springboot.zip. Extract this file and import this maven project to your Eclipse IDE.

3. Now create the HelloController.java in this spring boot project.
package com.nv.aws.ec2.springboot.awsec2springboot;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class HelloController {

    @RequestMapping("/")
    public String index() {
        return "AWS EC2 Springboot - Greetings from Spring Boot on AWS !!!";
    }

}


4. Open command prompt and go to the location where your project is imported. Now execute below command. This command builds and starts the spring boot application.

<YourDirectory>\aws-ec2-springboot>mvn clean install spring-boot:run

If you see below on your command prompt, this means your application is successfully started.



5. Try accessing application from your browser with below URL.
http://localhost:8080/

If this returns below page, your application is all set to be deployed on AWS EC2 instance.










Launch EC2 Instance
Now you need to launch EC2 instance on AWS. This post describes about how to launch a new Linux EC2 instance on AWS.

Java Installation on Launched EC2 Instance
To run a spring boot application on EC2 instance you need to make sure that java is installed on EC2 instance. Please refer this post to install java on linux EC2 instance.

Copy SpringBoot App to AWS EC2 Instance
Here we will use WinSCP to copy spring boot app from your local machine to AWS remote EC2 machine. We need .ppk file to connect to remote EC2 using WinSCP client. If you do not have .ppk file generated, please refer this post to have .ppk file. Now open WinSCP, connect to remote EC2 machine and copy spring boot application.















Start and Access SpringBoot App 
Access EC2 machine using Putty. This post describes about how to access Amazon EC2 Instance from Windows using Putty. Once you are able to access EC2 machine, you just need to execute below command. Since you have copied your spring boot application at location /home/ec2-user/aws-ec2-springboot-0.0.1-SNAPSHOT.jar, so make sure that you run below command from this location /home/ec2-user/

java -jar aws-ec2-springboot-0.0.1-SNAPSHOT.jar 

If you see below output, this means your spring boot application is successfully started on AWS EC2 instance.





Now finally use your EC2 IP to access web application on your browser.

http://<EC2-IP>:8080/    

http://10.205.168.99:8080/

If it returns below output on browser, you are done with running spring boot application on AWS EC2 instance.  Great Job !!.


Friday, 28 December 2018

AWS - Accessing Amazon EC2 Instance from Windows using Putty

If you have already launched AWS EC2 instance and looking for option to access that instance from Windows machine using Putty, this post may help you.In case, you have not already launched the AWS EC2 server, not a problem. Please refer this post to launch the Linux EC2 instance on AWS.

Prerequisite
1. Make sure that you have already installed Putty on your windows machine. If not please download and install.
2. While launching the EC2 instance, you must have saved .pem file (step#8 in this post). But Putty uses .ppk file instead of .pem file. You need to generate .ppk file from .pem file. Follow below steps to generate .ppk file.

A) Open PuTTYgen (<yourDirWhereYourDownloadedPutty>\putty\PUTTYGEN.EXE)


B) Choose Load on the right side
C) Set the file type to *.*
D) Browse and open your .pem file
E) PuTTY will auto-detect everything it needs, and you just need to choose Save private key and you can save your .ppk file.

Accessing Amazon EC2 Instance using Putty
1.  Open putty (<yourDirWhereYourDownloadedPutty>\putty\PUTTY.EXE)
2.  Fill the IP of EC2 box. If you are not sure about EC2 IP, refer step#11 from this post to locate the EC2 IP.

 3. Now you need to mention Auth file. Here you need to provide .ppk file that you just generated in prerequisite section above.

4. Once you choose Open, a dialog box is opened. Just select YES to connect to the server. When command prompt comes with login as, type user name as ec2-user  and enter. Now you are able to access the Linux machine you launched as EC2 on AWS. 



Sunday, 29 June 2014

MTPutty - Multi Tabbed Putty

If you are looking for the option where you can open Putty (free SSH and telnet client) sessions in multiple tabs, you reached to right blog. You can use MTPutty.

MTPutty is free and facilitates wrapping up multiple Putty applications in one tabbed interface. You can save user and password for remote connection to login automatically. This tool also provides facility to configure shell script that you may want to execute after remote server login. I think this is enough detail to know about MTPutty, isn’t it? If not you can refer more detail from here. Now let’s move to setting up and using MTPutty.

Installing and Setting up MTPutty

Before setting up MTPutty ensure to install Putty then only go for MTPutty installation.

Installing and setting up MTPutty in windows environment is quite simple. Download MTputty from here, execute downloaded setup file and provide the installation location. Once installation is done, you can open Mputty UI by executing ‘<mputty-installation-dir>/mtputty.exe’. When you open MTPutty first time you are prompted to provide the Putty executable file location. Once you will provide the Putty executable file location, you can see your Putty connections are imported into MPutty.


Adding New Connection in MTPutty:

To add the new connection in MTPutty, go to ‘Server > Add Server’. You will see below dialog box. Provide the required information like IP, user name, password, display name etc. and click 'OK' button.


You can see the new connection is displayed in left pane in MTputty UI. If you double click on this connection, new tab is opened in right pane and remote server is connected.

Configuring Script to Execute Automatically After Login

Right click on your added connection and click on ‘Script’ tab in opened dialog box. You need to configure two things. Wait period time and the shell script. Note that, shell script will be executed only after configured wait time. If your automatic login is done say in 3000 milliseconds, configure wait  period time around 4000 milliseconds to execute script.


I found this tool is interesting and useful. I hope this will also be useful for you. If you found this post helpful, your comments are most welcome.