# How to launch an instance in different cloud providers and perform the SCP command

Today, we will be creating a virtual machine in the different cloud providers like AWS, Google Cloud Provider (GCP), and Microsoft Azure. After creating the virtual machine we will connect to each machine via SSH protocol and we will try a demo of copying the sample file from our local machine to each VM using SCP protocol.

**SSH syntax:**

ssh -i private\_key user@ip

**SCP syntax:**

***scp -i private\_key file\_name user@ip:destination\_directory***

### AWS: EC2 Instance

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1695452603418/a54f17da-8df4-409b-bc07-1b601b9a3e77.png align="center")

From the services choose EC2 or search for EC2 in the search bar and click the EC2 service and click on "Launch Instance".

> sample details while creating the ec2 instance:
> 
> Name: ubuntuinstance
> 
> AMI: ubuntu (free tier eligible)
> 
> instance type: t2.micro (free tier eligible)
> 
> key pair: create a new key pair and download it
> 
> Remaining all keep as it is(Default). and click launch instance and view it.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1695452973640/e2748376-4f09-410d-aac0-e0dc02fb9294.png align="center")

Our ec2 instance is launched.

Let's connect to this ec2 instance from the local machine using the SSH command.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1695454701509/64de9c9b-c02c-4009-b496-7e1290ee84f0.png align="center")

We are successfully connected to the ec2 instance created in the AWS cloud.

### Copy a file from the Local machine to the EC2 instance

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1695455013365/998d8c3a-ceb0-4300-8217-4374bb7be7f5.png align="center")

Now let's verify in the remote ec2 instance whether the file is copied or not.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1695455062089/0242dcd1-1d9c-45d4-be35-00f394bdb8e7.png align="center")

We copied <mark>notes.txt</mark> from the local machine to the ec2 instance successfully.

### Copy a file from the remote VM to the Local machine

command: <mark>scp -i ~/Downloads/abc.pem ubuntu@13.127.142.222:~/awsinstance.txt /home/subash/Downloads/</mark>

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1695555922804/a28bc91f-b7e9-45d8-85d4-85e951f47d6d.png align="center")

Hence copied successfully.

### GCP: Virtual machine

Once you are logged into your Google Cloud platform. Click on the navigation menu at the top left corner or search on the search bar for "**compute engine"** From There you choose *VM instances* and click on *create instance*.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1695453942713/93919167-048d-4bbb-8110-25c5107b1111.png align="center")

After this click on the Create VM instance and fill in the details as follows:

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1695458235282/2c944546-7665-47f1-962e-a6f6719f57eb.png align="center")

We can see our VM is successfully launched.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1695458420827/995340a3-8aaf-46d3-a068-47b6a1a9a921.png align="center")

Let's connect to it via SSH command.

```plaintext
gcloud auth login #to get access to the gcp 
gcloud config set project project_id/name 
gcloud compute ssh instance_name --zone your_zone
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1695463723297/86059f3c-9b01-4452-8a37-5270fd9022b1.png align="center")

Finally, we are inside the VM as our hostname changed from **subash07** to **<mark>instance-4 </mark>** which is our VM's name.

### Copy a file from the Local machine to the Remote VM

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1695464080511/921f5f36-959b-4745-b6c8-fe37860fca25.png align="center")

Here we have copied a file notes.txt from our local machine to the GCP instance successfully.

### Copy a file from the Remote VM to the Local machine

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1695465416272/2b3be536-ce38-4dd1-9d42-f413083bd0d8.png align="center")

We copied a file named <mark>gcpinstace.txt</mark> from the GCP instance to our local machine.

### Microsoft Azure: create a virtual machine

Sign in with your Azure account credentials. Once logged in to the Azure portal we can see the following interface and click on create resource to create the instance.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1695548092332/7cb1357f-c122-498c-8fd6-e26f3326efac.png align="center")

After clicking on Create a virtual machine, the following interface is opened enter the details as required and create the virtual machine.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1695551184256/178bbeef-ebd8-4cab-8db8-ad9db6affa1a.png align="center")

Hence our virtual machine is successfully created as below:

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1695551309634/43fa09d7-9767-4b1b-9594-ba42d6f169db.png align="center")

Let's connect to our virtual machine from our local machine via SSH command.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1695551724599/5269fb22-868b-4867-b9ce-a8412fad8c73.png align="center")

We are successfully connected to our Azure virtual machine.

### Copy a file from the Local Machine to the remote VM

command:  
***scp -i ~/Downloads/testVm\_key.pem /home/subash/Downloads/notes.txt azureuser@20.40.56.201:~***

We copied a file named notes.txt to the virtual machine.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1695552574060/92b42837-d54e-4fdd-8fd9-aafb763187c4.png align="center")

Let's verify it in the VM.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1695552587922/53bc12f3-9e03-4457-b2e4-f69f4b0697cf.png align="center")

### Copy a file from the remote AzureVM to the Local machine

command performed: <mark>scp -i ~/Downloads/testVm_key.pem azureuser@20.40.56.201:~/azureinstance.txt /home/subash/Downloads/</mark>

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1695553097301/f8c927cd-0209-4312-bb86-b52a66bf599a.png align="center")

Here we can see our **azureinstance.txt** file locally in the Downloads folder.

Hence, in this blog, we did the following:

1. Creating a virtual machine in different clouds providers: AWS, GCP, AZURE
    
2. Connected to all the virtual machines via SSH command
    
3. Copied a file to and from the virtual machine using SCP command
    

Happy Learning !!
