SSH Connection to VM Deployments
- 1.
- 2.Search for the EC2 Virtual Service (you can type EC2 in the search bar at the top).
- 3.Select Instances on the left sidebar. You will see the list of the instances running in the current region. Click on the checkbox of the desired instance and then click on the Connect button on the top
- 4.Go to the SSH Client tab scroll to the bottom and copy the command under the example: paragraph. Paste it to your terminal and replace
root
withubuntu
before the@ec2
part. So as a result your command will look like thisssh -i "key.pem" [email protected]
but with your key name and IP of your instance. Beware that with the-i
option you should specify the path to the.pem
key file you saved during the VM creation process.
If you want to find the public DNS name of the instance using the CLI, you can run the following command to see the list of all instances in the current region:
aws ec2 describe-instances --query 'Reservations[*].Instances[*].{Instance:InstanceId,Subnet:SubnetId,Name:Tags,DNS:PublicDnsName}'
To log in to your Droplet via SSH, you need three pieces of information:
- the Droplet’s IP address
- the default username on the server (which is
ubuntu
in this case) - the password for that droplet, if you aren’t using SSH keys
We strongly recommend adding an SSH public key to your DigitalOcean account and choosing it as the authentication method during Droplet creation.
To connect to your Droplet:
- 1.Get your Droplet’s IP address, go to the DigitalOcean, and select Droplets from the sidebar. The IP address is displayed in the IP Address column after your Droplet has been created. You can put the cursor over it to copy it into your clipboard. 1.1 To get the IP of the droplet using the CLI, run this command:
doctl compute droplet list --format "ID,Name,PublicIPv4"
- 2.Go to your terminal and run
ssh [email protected]<ip>
(don't forget to paste the IP of your droplet)
- 1.
- 2.After that, you have two options: 2.1 Press the SSH button to the right of the VM you'd like to connect to. It will open a terminal session in your browser. 2.2 Press the⋮button and select the View gcloud command and use it inside your terminal to connect to the selected VM.
If you know
zone
, project_name
and name_of_the_instance
you can go to terminal and use the command immediately, skipping all the previous steps. The resulting command will be similar to gcloud compute ssh --zone "<zone>" "<name_of_the_instance>" --project "<project_name>"
Last modified 9mo ago