Quick post explaining how to connect Windows EC2 AWS server using RDP.
Connecting AWS Windows server using RDP
Step 1. Get windows password in AWS
Retrieve administrator password from the Windows EC2 server. Login to the EC2 dashboard from the AWS console. Select your Windows server EC2 instance and choose ‘Get Windows password‘ from the Actions menu.
Get windows password in AWS
Sometimes you may see below error complaining that Windows password is not available –
Windows password not available in AWS
Error is self explanatory. You are seeing it because –
You need to wait for your server to properly boot and module to start which decrypt windows password and share with you.
You spun windows server from AMI which does not have a module which could retrieve administrator password from Windows.
In the case of the first situation wait for few minutes and again try to ‘Get Windows Password‘. In the case of the second situation, you need to spin up EC2 with proper AMI.
Once the above issue is resolved, you will see the next window which asks for key pair you used while deploying the Windows server. This is AWS authenticating you again before it releases administrator password to you.
Key pair required to get windows password in aws
Browse key pair on your local machine and then hit the ‘Decrypt Password‘ button. If you have supplied proper key pair you will be presented with a password window like below –
Windows password in aws
That’s it. You have the administrator password for your Windows server on AWS.
Step 2 : Login to Windows AWS server using RDP
Logged in to Windows AWS server
Open remote desktop connection on your local machine. Punch in details that are given to you by AWS in the above window. Public DNS is the hostname you should use to connect to the server followed by the user name and password.
We have a 10GB EBS volume attached to the Linux EC2 server. /testmount of 9.9GB is created using this disk at OS level. We will be increasing it to 15GB.
root@kerneltalks # lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
xvda 202:0 0 10G 0 disk
└─xvda1 202:1 0 10G 0 part /
xvdf 202:80 0 10G 0 disk
└─datavg-datalv (dm-0) 253:0 0 9.9G 0 lvm /testmount
Step 1: How to extend EBS volume attached to the EC2 server in AWS
Login to AWS EC2 console, click on Volumes under Elastic Block Store in the left-hand side menu. Then select the volume you want to extend. From Actions drop-down menu select Modify Volume You will see below screen :
Modify EBS volume in AWS
Change size (in our case we changed from 10 to 16GB) and click Modify. Accept the confirmation dialogue box by clicking Yes.
Once modify operation succeeded, refresh the Volume list page and confirm the new size is being shown against the volume you modified just now. Now, your EBS volume is extended successfully at the AWS level. You need to extend it at OS level now.
Step 2: How to re-scan new size of EBS volume in Linux & extend filesystem online
Since EBS volumes size has been changed you need to rescan it in OS so that kernel and volume managers (LVM in our case) should make a note about the new size. In LVM, you can use pvresize command to rescan this extended EBS volume.
After successful rescan, check if the new size is identified by the kernel or not using lsblk command.
root@kerneltalks # lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
xvda 202:0 0 10G 0 disk
└─xvda1 202:1 0 10G 0 part /
xvdf 202:80 0 16G 0 disk
└─datavg-datalv (dm-0) 253:0 0 9.9G 0 lvm /testmount
You can see in the above output, now xvdf disk is shown with size 16G! So, the new disk size is identified. Now proceed to extend file system online using lvextend and resize2fs. Read how to extend the filesystem online for more details.
root@kerneltalks # lvextend -L 15G /dev/datavg/datalv
Extending logical volume datalv to 15.00 GiB
Logical volume datalv successfully resized
root@kerneltalks # resize2fs /dev/datavg/datalv
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/datavg/datalv is mounted on /testmount; on-line resizing required
old desc_blocks = 1, new_desc_blocks = 1
Performing an on-line resize of /dev/datavg/datalv to 3932160 (4k) blocks.
The filesystem on /dev/datavg/datalv is now 3932160 blocks long.
Check if the mount point is showing new bigger size.
root@kerneltalks # df -Ph /testmount
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/datavg-datalv 15G 153M 14G 2% /testmount
Yup, as we planned /testmount is now 15G in size from 9.9GB earlier size.
An article explaining step by step procedure to add EBS disk on AWS Linux server with screenshots.
EBS disk addition on AWS instance
Nowadays most of the servers run on cloud platforms like Amazon Web Services (AWS), Azure, etc. So daily administrative tasks on Linux servers from AWS console is one of the common things in sysadmin’s task list. In this article, we will walk you through one such task i.e. adding a new disk to the AWS Linux server.
Adding a disk to the EC2 Linux server has two portions. The first portion is to be done on AWS EC2 console which is creating new volume to be attached to the server. And attaching it to EC2 instance on AWS console. The second portion is to be done on the Linux server which is to identify newly added disk at the kernel level and prepare it for use.
Creating & attaching EBS volume
In this step, we will learn how to create EBS volume in the AWS console and how to attach EBS volume to AWS EC2 instance.
Login to your EC2 console and navigate to Volumes which is under ELASTIC BLOCK STORAGE menu on the left-hand sidebar. You will be presented with the current list of volumes in your AWS account like below –
Create volume in AWS
Now, click Create Volume button and you will be presented with the below screen.
Volume creation in AWS
Here you need to choose several parameters of your volume –
Volume Type. This decides your volume performance and obv billing.
Size. In GB. Min and Max available sizes differ according to your volume type choice.
IOPS. Performance parameters. Changes according to your volume type choice
Availability Zone. Make sure you select same AZ as your EC2 instance
Throughput. Performance parameter. Only available for ST1 & SC1 volume type.
Snapshot ID. Select snapshot if you want to create the new volume from existing snapshot backup. For fresh blank volume leave it blank.
Encryption. Checkmark if you want the volume to be encrypted. An extra layer of security.
Tags. Add tags for management, reporting, billing purposes.
After selecting proper parameters as per your requirement, click Create Volume button. You will be presented with ‘Volume created successfully’ dialogue if everything goes well along with the volume ID of your newly created volume. Click Close and you will be back of the volume list.
Now check volume ID to identify your newly created volume in this list. It will be marked with an ‘Available’ state. Select that volume and select Attach volume from Actions menu.
Attach volume menu
Now you will be presented with an instance selection menu. Here you need to choose an instance to which this volume is to be attached. Remember only instances in the same AZ of the volume are
Attach volume instance selection
Once you select the instance you can see the device name which will be reflected at the kernel level in your instance under Device field. Here its /dev/sdf.
Check out the note being displayed here. It says : Note: Newer Linux kernels may rename your devices to /dev/xvdf through /dev/xvdp internally, even when the device name entered here (and shown in the details) is /dev/sdf through /dev/sdp.
It says newer Linux kernels may interpret your device name as /dev/xvdf than /dev/sdf. This means this volume will be either /dev/sdf (on the old kernel) or /dev/xvdf on the new kernel.
That’s it. Once attached you can see volume state is changed from Available to in-use
Identifying volume on Linux instance
Now head back to your Linux server. Log in and check new volume in fdisk -l output.
root@kerneltalks # fdisk -l
WARNING: fdisk GPT support is currently new, and therefore in an experimental ph ase. Use at your own discretion.
Disk /dev/xvda: 10.7 GB, 10737418240 bytes, 20971520 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: gpt
Disk identifier: 25D08425-708A-47D2-B907-1F0A3F769A90
# Start End Size Type Name
1 2048 4095 1M BIOS boot parti
2 4096 20971486 10G Microsoft basic
Disk /dev/xvdf: 10.7 GB, 10737418240 bytes, 20971520 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
As AWS mentioned new device name will be reflected as /dev/xvdf in the kernel, you can see /dev/xvdf in the above output.
Now you need to partition this disk using LVM (using pvcreate) or fdisk so that you can use it for creating mount points!
Learn how to transfer files between desktop and EC2 using WinSCP. Using key-based authentication, winSCP can be connected to EC2 to download/upload files from/to the server.
Transfer data to/from EC2 using winSCP
While working on the EC2 server hosted on AWS, one of the basic requirements you come across is to transfer data between your desktop/laptop and EC2 instance. Since EC2 uses key-based authentication, for beginners it’s hard to understand how to transfer data from desktop to EC2 cloud.
Normally, programs like WinSCP are used to transfer data between the Linux server and the windows machine. In this article we will walk you through how to add key-based authentication in WinSCP. Later how to download files from EC2 to the local machine.
Other EC2 related posts which might interest you :
Make sure your EC2 instance is spun up. You have the Public DNS name of your EC2 instance. You can see it under instance description in your AWS EC2 console.
Open WinSCP tool. Click on Advanced to open settings of tool.
Open winSCP settings
Under settings, click on Authentication under SSH in the left panel. This will open up authentication settings on the right panel.
Authentication settings in winSCP
Under, Authentication parameters tick ‘Allow agent forwarding‘ and browse your private key file in it. This private key file is key the same file you use to authenticate to EC2 when connecting via PuTTY
Click OK and close settings.
Step 3 : Connect
Copy public DNS of your EC2 instance, username as ec2-user for RedHat (different Linux distro has diff default logins in AWS. List of all is here) and hit connect. It will pop up to accept the key if you are connecting for the first time via WinSCP. Accept it and you will be connected to the EC2 server!
I have created small GIF which shows whole above process. Have a look .
Connect EC2 using winSCP
Now you can download or upload files from EC2 to local like you normally do!
Learn how to disassociate elastic IP from EC2 and how to release elastic IP in AWS with screenshots. Also, understand how elastic IP is billed and the cost of billing.
How to guide: Release Elastic IP in AWS
In our previous article we understood how to allocate elastic IP to your AWS account & how to associate that elastic IP to EC2 instance. In this article we will walk through steps to disassociate elastic IP from EC2 instance and then release elastic IP from your AWS account.
Before we run into steps lets look at elastic IP billing information which will help you to judge why it is important to release un-used elastic IP back to AWS.
Elastic IP billing
At the most you can allocate 5 elastic IP for an AWS account per region. If you have a requirement of more, you need to reach out to the AWS team to raise this limit through form. This limit is set by Amazon since IPv4 is a scarce resource.
Coming to the billing part, you will be billed for each elastic IP which is not being used anywhere but allocated to your AWS account. This is to impose efficient use of such scarce resources. You will not be billed for elastic IP if below conditions are met –
Elastic IP allocated to you is associated with EC2 instance
That EC2 instance has only one elastic IP associated
Elastic IP is allocated to you once you demand it. There is no default elastic IP allocated to your AWS account. Hence elastic IP billed under on-demand pricing model. Here are points to consider :
Elastic IP billed under an on-demand pricing model
It’s billed per hour on a pro-rata basis.
Billing rate changes as per region. Detailed rates are available on the pricing page under the ‘Elastic IP Addresses‘ section.
For example, see below rates of elastic IP for US East (Ohio) region depending on your type of use –
Elastic IP billing information. Information credit : AWS website.
Now, you know how your usage gonna get billed for elastic IPs in AWS. Without further deviation, let’s walk through process to release elastic IP from the AWS account.
How to remove elastic IP from EC2 instance
In AWS terms, its process to disassociate elastic IP from EC2 instance. The process is pretty simple. Login to EC2 console and navigate to Elastic IPs. You will be listed with all available Elastic IPs in your account. Choose one to disassociate and choose disassociate from the action menu. You will be shown a pop up like one below :
Disassociate elastic IP from EC2
Confirm disassociation by clicking the disassociate address button. Your elastic IP will be removed from an EC2 instance and the instance will be assigned with public IP from AWS automatically. You can confirm empty elastic IP from EC2 instance details.
Now you have successfully disassociated elastic IP from EC2 instance. But it is still allocated to your AWS account and you are getting billed since you are not using it anywhere. You need to release it back to the AWS pool if you are not planned to use it for any other purpose so that you won’t be billed for it.
How to release elastic IP from AWS account
Releasing elastic IP means freeing it from your account and making it available back in the AWS pool for someone else to use it. To release login to EC2 console and navigate to Elastic IPs page. From the presented list select elastic IP you want to release and choose release address from the actions menu. You will be prompted with pop up like below :
Release elastic IP from AWS account
Confirm your action by hitting the release button. Your elastic IP will be released back to the AWS pool and you won’t be able to see it in your account anymore!
Learn how to assign elastic IP to the ec2 Linux instance in AWS. Step by step procedure explaining how to allocate elastic IP to your account and how to associate it to EC2.
Associate Elastic IP to EC2 instance tutorial
In this article we will walk through steps to assign elastic IP on Linux EC2 instance. First of all you might think what is elastic IP and why to use it? We have already covered here elastic IP basics and the difference between elastic and public IP. Without further delay lets move onto our tutorial of assigning elastic IP to EC2 instance.
Get ready your EC2 for Elastic IP
First of all you should have launched your EC2 instance. It should be in a running state. Once running you can check instance properties in EC2 console under AWS dashboard and its IP details should be as below :
EC2 instance without Elastic IP
Here you can see the Elastic IP field is empty and the Public IP field is populated with AWS auto-assigned IP address.
Remember, only one of these two exist for EC2 instance; either public or elastic IP.
Allocate Elastic IP to AWS account
The second step is to allocate your AWS account new Elastic IP if you haven’t allocated any elastic IP before.
Note that only 5 elastic IP can be allocated to a single AWS account and you will be charged for any elastic IP which is not being used.
Let’s see how to allocate an elastic IP to the AWS account. Navigate to VPC under your AWS dashboard. You will be presented with the VPC console where on the left pane you can find the ‘Elastic IPs‘ menu. Click on that to open the Elastic IP dashboard. Here you see the‘Allocate New Address‘ button. On the next screen click ‘Allocate‘ and you will be allocated with new Elastic IP in your account. I created GIF (below) of the whole process for your reference.
Associate Elastic IP to EC2 instance
Now you have one elastic IP allocated to your account. You need to associate this IP to EC2 instance. Again head back to Elastic IP dashboard where you will see your newly allocated elastic IP. Select it and choose ‘associate address‘ from the action menu. You will see pop up like below :
How to associate Elastic IP to EC2
Select the resource type as an instance. Select your EC2 Instance from the dropdown. Private IP{ is elastic IP which you are associating now (pre-populated).
Here you can see a warning if you associate elastic IP with instance your public IP will be released. This is what we mentioned in the first part of this tutorial that only one IP can exist.
Once associated you can check IP details as below :
Elastic IP details
where you can confirm that it is associated with EC2 instance by verifying ‘Instance‘ field value.
Verify Elastic IP on EC2 instance
You are done! You already associated your elastic IP to EC2 instance. Now you can verify it with all the below methods :
Go to the EC2 console and check the instance details. You will see the Elastic IP field is populated and Public IP field reflects elastic IP as below :
Article listing benefits of cloud over traditional datacenter. 7 different aspects of cloud vs on-premise datacenter.
Cloud vs traditional datacenter
In the past few years, the cloud industry is gaining good momentum. Many companies are moving their workloads to cloud from the traditional data centers. This trend is increasing day by day due to the list of advantages cloud offers over the traditional data centers. In this article we will walk through these advantages of cloud over traditional datacenter. This is also one of the basic cloud interview questions where they tell you to list of pros and cons of the cloud. Without much delay lets jump into cloud vs data center discussion.
Low maintenance cost. For a customer maintenance cost is almost nil. Since you are using hardware from the cloud provider’s datacenter, you don’t need to maintain hardware at all. Your cost is saved from geographical location cost, hardware purchase, upgrades, datacenter staff, power, facility management cost, etc. All this is bared by the cloud provider. Also, for cloud providers, this is also low since they are operating multiple clients from the same facility and hence cost is low compared to cost one has to bear when all those clients are operating from different datacenters. This is very much environment friendly too since you are reducing the need for multiple facilities to fewer ones.
Cheap resources. Cloud providers have a pool of resources and from which you get assigned your share. This means cloud providers maintain and operate a large volume of resources and distribute smaller chunks to customers. This obviously reduces the cost of maintenance and operation for cloud providers and in turn provides low cost, cheap resources to customers.
Scale as per your need. In a traditional data center you have to study and plan your capacity well in advance to finalize your hardware purchase. Once purchased you are stuck with purchased limited capacity and you can not accommodate if capacity requirement grows beyond limit before your estimated time. It again goes through planning, purchasing new hardware which is a time-consuming process. In the cloud you can scale up and scale down your computing capacity almost instantly (or way shorter in time than traditional purchase process). And don’t even need to worry and follow for approvals, purchase, billing, etc things.
Pay as you use. In traditional data centers whenever you buy hardware you make an investment upfront even if you don’t use the full capacity of purchased hardware. In the cloud, you are billed per your use. So your expenditure on computing is optimum with your use.
The latest technology at your service. Technology changing very fast these days. Hardware you buy today becomes obsolete in a couple of months. And if you are making huge investments in hardware, the company expects to use it at least for a couple of years. So you are stuck with the hardware you brought with a nice price tag and now way behind from its latest counterparts. Cloud provides you the latest tech always and you don’t need to worry about upgrades or maintenance. All these hardware aspects are the headache of cloud providers and they take care of it in the background. As a customer, all the latest technology is at your service without any hassle.
Redundancy. Redundancy in traditional datacenter means cost investment to build almost identical facilities of the primary. Along with it also involves cost for infrastructure which connects them. Also, on-site redundancy for power, network, etc. is also expensive and maintenance prone. When you are opting cloud, everything said previously is just vanished from your plate. Cloud at single entity level like single server, storage disk, etc is already redundant. Nothing to be done and no extra cost is being billed to you for it. For your infra design requirement if you want, you can use ready-made services provided by cloud (for redundancy) and you are all set from failures.
Accessibility. With an on-premise datacenter, you have very limited connectivity mostly locally. If you want access to inside entities, you need to maintain your own VPN. Cloud services have a portal with access to almost all of their services over the web. It can be accessed from anywhere with internet. Also, if you want to opt-in for a VPN, you get a pre-configured secure VPN from your cloud provider. No need for designing and maintaining a VPN!
Let us know your views on cloud vs on premise datacenters in comments section below.
Learn what is elastic IP and public IP means in AWS. List out all differences between elastic IP and public IP in AWS.
Elastic IP vs Public IP in AWS
I was having a conversation about AWS with one of my friends and he came up with the question what is the difference between elastic IP and public IP? So, I explained to him and thought why not draft a post about it! So in this article, we will see the difference between elastic IP and public IP in AWS. This can be a cloud interview question so without much delay lets get into elastic IP vs public IP battle.
What is elastic IP in AWS?
First thing first, let’s get basics clear. What is the elastic IP? It is IPv4 IP address designed and exists for dynamic cloud computing and reachable over the internet. By name, you can imagine it’s a flexible IP that can be used or mapped rapidly from one EC2 instance to another when a currently associated instance fails. This way end-user or application continues to talk to the same IP even if the instance behind it fails. They are like static public IPs allocated for your AWS account.
What is Public IP in AWS?
Public IP is IPv4 IP address which is reachable over the internet. Remember switching flexibility of Elastic IP is not available for this IP. Amazon also assigns external/Public DNS name (shown in the screenshot) to instances who receives public IP. The public IP of the instance is mapped to the primary private IP of that instance via NAT (Network Address Translation) by default.
Refer below screenshot from the EC2 console of AWS and observe where you can check your elastic IP, public IP, and public DNS name.
Check elastic IP, public IP and public DNS in EC2 AWS console
Difference between elastic IP and Public IP
Now let’s look at the difference between these two IP types.
Whenever a new EC2 instance spins up, it’s assigned with public IP by default. Elastic IP is not assigned by default.
Elastic IPs are assigned to AWS accounts which you can attach to instances. Public IPs assigned to instances directly.
When an instance is stopped and started again, public IP gets changed. But if the instance is assigned with elastic IP, it will remain the same even if the instance is stopped and started again.
If elastic IP is allocated to your account and not in use then you will be charged for it on an hourly basis.
Public IP released once your instance is stopped so no question of getting charged for not using it.
You won’t be able to re-use the same public IP since its allocated from the free IP pool. You can always re-use, re-attach elastic IP to other instances when it is released from the current instance.
You can not manually attach or detach public IP from the instance. It’s auto allocated from the pool. Elastic IP can be manually attached and detach from the instance.
You can have a maximum of 5 elastic IP to your account per region. But, you can have as many public IPs as EC2 instances you spin up.
You can have either of them for an instance. If you assign elastic IP to instance then its currently assigned public IP will be released to the free pool.
An overview of the global data center presence of top Cloud companies like AWS, Google Cloud, Azure, etc. This article lists maps and links which will help you understand the data center presence of various firms.
Data center presence of Cloud providers
All companies are moving to the cloud now. Since the cloud model aims at pay-per-use its best fit in cost-cutting for every company that works in the IT field. The latest hardware and technologies are at your service without investing and worrying about the maintenance of hardware and facilities is the biggest benefit luring customers to cloud companies.
Since the cloud is a hot cake and its demand is growing day by day, we see lots of players in the cloud providers market. It’s not easy to offer cloud services since you need huge facilities all over the globe rather a network of such facilities across the globe to build your own cloud. It’s not an easy task, not at all! Data centers are the backbone of these clouds. They house the hardware which actually runs cloud services. So it’s important to know your cloud provider’s data center locations which helps you deciding many aspects of your services before moving in.
Here in this article, we will be listing all top-level cloud provider’s data center locations. This information is available on their respective websites, but we are consolidating it here for your quick reference!
Below data is as on 24th May 2020
Amazon Web Service (AWS)
AWS global infrastructures consist of 24 regions with 76 availability zones within & 216 Point of Presence. Zone normally indicates one or more datacenter. The latest updated details can be found on their page here. AWS global infrastructure map looks like :
AWS Global Infrastructure. Image credit : Amazon
Where, numbers denote the number of availability zones in that region and green circles show upcoming regions.
AWS Infrastructure is visually represented on this website which is nice to understand.
Google Cloud Platform
Another biggie in the Cloud service market. Google has a presence in 23 regions with 70 zones within & 140 Network Edge Locations. Google also shared their network map details along with data center presence here on this page. Their global locations map looks like below :
Google Cloud global locations. Image credit : Google
Where number denotes available zones and blue ones are upcoming locations.
Microsoft Azure
Azure is a cloud service from Microsoft. Their global infrastructure consists of 60+ regions. The latest and updated info can be grabbed from this page. Microsoft’s data center map looks like one below :
Microsoft Azure global infrastructure map. Image credit : Microsoft
Where triangle ones are upcoming locations.
IBM Bluemix
IBM offers its cloud platform as a service in Bluemix. The latest updated infra details can be found here on this page.
IBM Bluemix data centers. Image credit : IBM
HP Cloud
I could not find infrastructure maps or consolidated information for the Hewlett Packard (HP) cloud global infrastructure. However I got some info on the HP UK website here. Where HP states they have 28 data centers powering their cloud and they are building new 5 data centers in the EMEA region.
vCloud
VMware cloud also referred to as vCloud has 11 zones in a total of 4 countries. VMware doesn’t define regions, rather they deny zones within countries. VMware released this PDF which has all these details.
So looking at above maps and numbers we can jot down current infrastructure reach of three top cloud companies in below table :
Amazon web services
Google Cloud
Microsoft Azure
Regions
16
11
36
Zones
44
33
Upcoming regions
5
6
6
Every company uses different terminology. Where regions are common for all but not zones. Zones are referred to as single or multiple data centers in that geographical vicinity. Microsoft, IBM doesn’t refer zones term they only refer to regions. VMware doesn’t refer regions they only refer to country-wise zones. So the exact data center count for each company is not known rather shouldn’t be!
Let us know if you have more information of links regarding data center details of cloud providers (publically made available by owners) in comments below.
Learn how to rsync to EC2 with the help of SSH protocol authenticated using a private key file. The process can be used for Rsync from and between EC2.
Rsync to EC2 Linux instance
We learned about Rsync in our last post. We learned how Rsync helps in a data backup or mirroring by using less bandwidth, time on the second run. Since it syncs only changes in later executions after the first fresh copy operation. Now many traditional data centers are moving to cloud services like AWS. Rsync can be useful to sync data from your local server to AWS hosted EC2 instance (if the data size is not huge).
In this article we will learn about how to rsync to EC2 server in AWS. Since you know EC2 Linux instances don’t use a conventional used id-password combination for authentication, Key pairs need to be used in Rsync for authentication EC2. For the Rsync setup, your EC2 instance must be launched with public-private key pair and you should have a private key file with you.
Get started
To start with making sure your EC2 instance is launched with a key pair.
Upload private key file on the source server (from where you are going to Rsync to EC2)
Make sure key file set with 400 permission
Get public IP or public DNS name of EC2 server from AWS EC2 console web page
Confirm you are able to connect from source to EC2. (verify AWS security groups and firewall settings)
Execute Rsync to EC2
We have testfile.tar for testing copy and private key file (mykey.pem) ready on the source server.
[root@kerneltalks ~]# rsync -avz -e "ssh -i /root/mykey.pem" testfile.tar ec2-user@ec2-13-126-114-120.ap-south-1.compute.amazonaws.com:/tmp/
sending incremental file list
testfile.tar
sent 8520069 bytes received 31 bytes 3408040.00 bytes/sec
total size is 39198720 speedup is 4.60
Where –
-a: Archive mode preserves permission and ownership
-v: verbose mode
-z: compress
-e: Choose remote shell of execution
ssh -i keyfile: Use the private key for authentication on destination using ssh protocol
source (testfile.tar)
Destination: Public DNS name of EC2 instance
That’s it! Your file is copied over to EC2. This can be done vice versa as well. You can sync files from the EC2 server to the local server as well. Just switch source-destination paths and you are all set to go.
Rsync between two EC2 servers
Rsync can be executed between two EC2 servers i.e. from one EC2 server to another. The same above command can be used. If you are doing it for EC2 instances within the same region then the Internal DNS name can be used in a command.
Conclusion :
Rsync is possible from, to, and between EC2 servers. Key file authenticated SSH protocol should be used in the Rsync command to achieve this.