Question: I have installed Jenkins on my local, I have created my own EC2 instance, I can ssh into my instance and run some shell scripts to shut down my Wildfly server installed on my instance.

This is what I do when I do it manually on my Mac.

1. open my mac terminal, type 

`ssh -i /Users/xxx/tools/xxxx.pem ubuntu@10.206.xxx.xx`
2. It will login to my Instance, and then I type:

`cd /srv/wildfly-10.1.0.Final/bin`

`sudo -s`

`source /etc/profile`

`./jboss-cli.sh --connect command=:shutdown`
3. The screen will output

> 
> {"outcome" => "success"}
> 
> 
> 

Now, I want to using Jenkins, when I click build button, it will ssh into that instance and run these shell scripts for me. The output is expected the same as I run it after I ssh into the instance.

My question is: what steps should I follow, after I login to my Jenkins local environment: localhost:8080

Create a New Item, which one? Is there some plugin I can use? Where to put my shell scripts, will it run successfully?

A guide would be helpful, thanks a lot!

Additon:
when I try to login: using my ssh command, I get this error:

```
Pseudo-terminal will not be allocated because stdin is not a terminal.
Host key verification failed.

```

Answer: 
Too many questions to answer in one post. but this should get you started. 

1. ssh from jenkins to your ec2 should be password less, should you need to set the keys in jenkins. use the credential manager and create one, by pasting the private key

<https://www.cloudbees.com/blog/using-ssh-jenkins>

2. Refer remote command execution over ssh for the rest of the task. 

	* you will find how to do this in tons.. but this should give you an idea. <https://www.cyberciti.biz/faq/unix-linux-execute-command-using-ssh/>
3. For the question on job type, at this point just go with the `freestyle` .. And later, you may plan for fancy stuff.
You need to add the PEM file details in place where it asks for Private Key