SSH into a DigitalOcean Droplet using Password Authentication
Tags: webdev, beginners, programming, tutorial
Published: 2023-10-19 18:43:22

Are you someone who is a junior developer struggling to climb up the corporate ladder and become a senior developer?

Are you a full-stack developer who feels lost and doesn't know where to start? 🤔

Well, you are in the right place! 😎

### Why learn SSH?

- SSH plays an important role in secure remote communication. By familiarizing yourself with SSH basics, its commands, encryption methods, SSH key management, and applying SSH for real-world applications, you're well on your way to becoming a Senior Developer.
- Check out my previous blogs: [SSH 101](https://dev.to/aswin2001barath/ssh-101-junior-to-senior-web-dev-roadmap-2l31) and [SSH Command](https://dev.to/aswin2001barath/ssh-command-junior-to-senior-web-dev-roadmap-210g) to learn more about What is SSH, Commonly known protocols, SSH in comparison with HTTPS and SSL, Significance of SSH and SSH command.
- In this blog, I will use my SSH skills by connecting my local computer to a cloud service provider such as [**DigitalOcean**](digitalocean.pxf.io/rQbELR). This hands-on experience will help solidify your understanding of SSH concepts.

### Demonstration: Spin up a Droplet on DigitalOcean

- Visit [**DigitalOcean**](digitalocean.pxf.io/rQbELR) which is a cloud service provider that gives us servers for a really cheap price. Sign up and get a $200, 60-day credit to try their products using this link: https://m.do.co/c/201036484da7

![DigitalOcean Homepage](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wll4l6gjnjvlmaqs2e8b.png)

- Go to [**Droplets**](digitalocean.pxf.io/ZQ4VL1) in the prodcuts section and create a Droplet. Droplet is DigitalOcean's version of the server we can purchase. It's sort of a nickname, I guess.


![Droplets Homepage](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/u394eyy7tpf9vu5gw4ng.png)

- Then, you will be greeted with the Droplet set-up page. Here, first, you will be asked to choose a Region, where the Datacenter will be located. Here select a region that's closest to your location. In my case, it's _Bangalore_.


![Droplet set-up page](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/859tpf7k1kvkvbs8k7ry.png)

- Choose **Ubuntu** as the Server Image. Ubuntu is an Open-source Operating System built on top of Linux. Most servers out there in the world use Ubuntu as the standard Operating System.

![Choose Ubuntu Server Image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0evjzd7v77dzb8mbazzu.png)

- Now, Choose a CPU size. My advice is to choose the cheapest size for this demonstration. In my case, I chose the Basic plan as the Droplet Type, which is a shared CPU.


![Choose a CPU size](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/k3b6n24wp3nmfsl2s97l.png)

- For CPU options, I chose the _Regular Disk Type: SSD_ and $6/month plan. You can do the same, as this much CPU is more than enough for this demonstration.

![CPU options](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0a5b7ry5q7xi7464xa3u.png)

- Now you can choose any of the two Authentication Methods: (1) Password Authentication or (2) SSH Key Authentication. I chose Password Authentication for the simplicity of this demonstration.

![Authentication Methods](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/j4mmfau7hqts472v9jn5.png) 

- Next, you have to create a strong password for the root user of the Ubuntu Server Image.

![Create a strong password](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uj1khfime3btd4jcla2n.png)

- Finally, you can provide a user-friendly hostname and Create a Droplet successfully.

![Provide a user-friendly hostname](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7keu5e36js4ov6bihbia.png)

- Once the Droplet is created, copy the **ipv4** address. Because we will use the IP address to connect with the DigitalOcean Droplet with an SSH connection. 

![Copy IPv4 address](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hb3hvmj7s3qr1lfpd4zl.png)

- Now open the terminal if you are using the MacOS or Linux OS, and Command Line (CMD) for Windows and type the SSH command in this format: `ssh root@{ipv4 address}`. 

![SSH Command on CMD](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/a1kr656b2f5im4hc2b4l.png)

- You will be asked if you want to connect, type **yes**. Then type the password correctly. I made a mistake in both of these steps which you can see evidently in the below screenshot.

![CMD Output](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1f0ecmt8cslkm0p70xef.png)

- As you can see, I successfully created an SSH connection with my DigitalOcean Droplet that's running a Ubuntu Server Image, in a very cheap shared CPU. How cool is that?

#### Running Linux Commands on the Ubuntu Server

Okay, now to convince you that I have actually connected to the Ubuntu Server running on the DigitalOcean Server, I'm going to run the following Linux Commands.
- ls - Lists the files and folders in the current directory
- whoami - displays authentication information for the current user
- mkdir - used to make a new folder
- cd - used to change the working directory

![Linux Commands](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3fa3t59jpil66q8czdu9.png)

- Finally, you can type **exit** to log out of the session and close the SSH connection with the DigitalOcean Droplet.

![SSH Connection Session Log out](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bfotk2cru6do0kmsrsmh.png)

- Make sure that once you play around with the Ubuntu server using SSH you log out and delete the Droplet using the **Destroy** button that you can see in the DigitalOcean Droplet Page.

![Destroy Droplet](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/otqdx5sa63rg0ywi82tw.png)

- Now you must have realized that using SSH, we can connect to this remote computer and run commands on it.
- Using SSH, we can connect to any computer that allows for these SSH connections from anywhere in the world. How cool is that? 😉

### What next?

Learn more about the following topics with the help of the resources provided at the end of this blog to solidify your knowledge in _SSH_

- **SSH Commands**: One of the primary uses of SSH is to execute commands on remote computers. This means you can establish a connection to a server and interact with it using SSH commands.

- **Encryption**: To truly grasp SSH, it's important to understand key concepts such as encryption, which involves both symmetric and asymmetric encryption techniques, as well as hashing. These concepts lay the foundation for a deeper understanding of SSH's security mechanisms.

- **SSH Keys**: An integral part of SSH is the use of SSH keys. These keys consist of a public key and a private key. Learning how to generate, manage, and securely store these keys on the server is crucial for effective SSH usage.

- Practice and Test your SSH skills:
  - A great way to practice your SSH skills is by connecting your local computer to platforms like **GitHub** or cloud providers such as [**DigitalOcean**](https://m.do.co/c/201036484da7). This hands-on experience will help solidify your understanding of SSH concepts.
  - Imagine this scenario: "Your web application mysteriously disappears from the server overnight. Your task is to restore all project files onto the server using SSH." Successfully completing this task showcases your SSH skills and your problem-solving abilities. Basically, if you can do this, you're awesome!

### Best Resources

Learn more about _SSH_ with the help of the following short and concise resources:

- Learn about [how SSH works](https://www.hostinger.com/tutorials/ssh-tutorial-how-does-ssh-work), and [how to SSH into a server](https://www.digitalocean.com/community/tutorials/understanding-the-ssh-encryption-and-connection-process).
- Learn a little about [Symmetric and Asymmetric encryption](https://www.youtube.com/watch?v=GSIDS_lvRv4) as well as [Hashing](https://www.youtube.com/watch?v=b4b8ktEV4Bg)
- Learn how to [manage SSH keys](https://www.youtube.com/watch?v=DbPDraCYju8)

Learn more about the _Junior to Senior Web Development Roadmap_ with the help of the comprehensive resources:

- [Junior to Senior Web Developer Roadmap Blog Series](https://dev.to/aswin2001barath/series/24357): A Blog series where I will be learning and sharing my knowledge on each of the above topics.
- [Don’t be a Junior Developer: The Roadmap From Junior to Senior](https://academy.zerotomastery.io/a/aff_5s8ff6y7/external?affcode=441520_dcwk-s8s): A detailed roadmap blog by Andrei Neagoie (a Senior Developer) with links to free resources.
- **Zero To Mastery Course**: [The Complete Junior to Senior Web Developer Roadmap Course](https://academy.zerotomastery.io/a/aff_hpwn5xy9/external?affcode=441520_dcwk-s8s): A comprehensive course by Andrei Neagoie (the same Senior Developer) that covers all of the above topics.

### **Who Am I?**

- I’m Aswin Barath, a Software Engineering Nerd who loves building Web Applications, now sharing my knowledge through [Blogging](https://medium.com/techsoftware) during the busy time of my freelancing work life.
- I'm also a Junior Developer like you learning how to become a Senior Developer and sharing my knowledge along the way.
- Here’s the link to all of my socials categorized by platforms under one place: https://linktr.ee/AswinBarath

**Thank you** so much for reading my blog🙂.