Friday, November 1, 2019

How many ways we can connect with AWS-EC2 instance and access files


Method 1 : (AWS EC2- Jenkins Master & Local Linux Machine)
1. Connection established between Local Linux machine and Jenkins Master using "jenkinsmaster.pem“
1.1 Run Jenkins on Local Linux machine and create the job to get the Binaries from the AWS Jenkins
1.2 Using SSH command to connect the instance for the AMI(Amazon Machine Image) & the public DNS name
cmd: SSH -i /path/to/jenkinsmaster.pem ec2-user@public-DNS-ipaddress.amazonaws.com
1.3 Using SCP(Secure Copy) transfer or copy the required libraries(Binaries) from source folder (/home/admin/Binaries) and copy to the destination folder in the Local Linux Machine.
cmd: scp -rp -i /path/to/jenkinsmaster.pem ec2-user@public-DNS-ipaddress.amazonaws.com:/home/ubuntu/Binariesfolder [Jenkins Master] /home/admin/.Jenkins/workspace/testjob [Local Linux Machine]
1.4 execute the automation scripts once the latest files getting copied



Method 2 : (AWS EC2- Jenkins Master & Local Linux Machine)
1.1 Run Jenkins on Local Linux machine and create job to get the Binaries from the AWS Jenkins using "ppk“(putty private key)
1.2 Using PSCP (Putty Secure Copy) command to connect the instance for the AMI(Amazon Machine Image) & get the required binaries / files from the "Source folder</Binaries>“ to <Destination folder> i.e. /home/admin/.Jenkins/testjob/
cmd: pscp -i </home/admin/aws-ubuntu.ppk> ubuntu@ec2-18-217-240-11.us-east-2.compute.amazonaws.com:/home/ubuntu/Binaries /home/test/jenkinstest/testjob
1.3 Extract the "Linux.tar.gz“ file and copy the files to specified folders /home/ubuntu/<folderName>

Method 3:
1 Create a "config” file inside the ".ssh“ folder and move the "masterjenkins.pem“ file to .ssh folder and paste this code to config file
Note : in this method key will not be displayed / leaked to anyone, it will be copied inside a /.ssh/config file
Host ec2
Hostname ec2-3-60-210-18.us-east-1.compute.amazonaws.com
User ubuntu
IdentityFile ~/.ssh/masterjenkins.pem
and type the below command to connect with cloud Jenkins master in the below image

No comments:

Post a Comment

How to install and setup Kubernetes cluster using kOps in AWS environment

  Kops: Kops is also known as Kubernetes Operations, it is an open-source project which helps you to create, upgrade, destroy, and maintain ...