DEV Community

Cover image for SSH into a DigitalOcean Droplet using Password Authentication
Aswin Barath
Aswin Barath

Posted on

SSH into a DigitalOcean Droplet using Password Authentication

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 and SSH Command 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. This hands-on experience will help solidify your understanding of SSH concepts.

Demonstration: Spin up a Droplet on DigitalOcean

  • Visit DigitalOcean 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

  • Go to Droplets 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

  • 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

  • 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

  • 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

  • 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

  • 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

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

Create a strong password

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

Provide a user-friendly hostname

  • 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

  • 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

  • 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

  • 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

  • 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

  • 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

  • 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. 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 more about the Junior to Senior Web Development Roadmap with the help of the comprehensive resources:

Who Am I?

  • I’m Aswin Barath, a Software Engineering Nerd who loves building Web Applications, now sharing my knowledge through Blogging 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🙂.

Top comments (0)