How to SSH into DigitalOcean with a Key (no password)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey everyone this is tony teaches tech i'm tony and in this video i'm going to show you how to log in via ssh to your digitalocean droplet without a password and the way we're going to do this is with something called an ssh key so let me show you how to do this all right so i'm here in my digitalocean dashboard and what i'm going to do is to create a new droplet and it really does not matter what type of droplet we're creating here i'm just going to do the 12 per month intel uh droplet right so but the the part that we're interested in is down here under the authentication section there's typically two ways that you can authenticate with a droplet meaning the how how are we going to log into the droplet are we going to type in a password which is this option here you can create a password that's probably what you're used to or you can create an ssh key that's going to live on your computer it's going to be a public private key pair and you're going to basically tell digitalocean about the public key so that when it goes and you know does all that cryptography behind the scenes and matches the public key with the private key then you are authenticated without even having to do anything because your public key private key acts like a token and as long as you're on your computer then you can access your droplet so let's go ahead and set that up i'm going to click on new ssh key here and it pretty much walks you through it uh it's going to be different for windows users and there's instructions specifically for them right here but if you're on a mac or a linux computer then that's what this specific tutorial that you're watching is going to show you how to do so what what we basically do is execute the ssh keygen command get some type of key output and then put that key output in this in the digital ocean dashboard so that's saved to your account um and then anytime you create a new droplet that's going to be associated with a droplet so that doesn't make sense let's go through step by step i'm going to open up a terminal window here and we're going to type in ssh keygen and that's going to say generating public private key rsa key pair so the file is going to say the key is at this location this is a hidden directory dot ssh and then the file name is going to be id rsa so that's fine we'll keep the default there enter passphrase you you may or may not want to do this it's more secure if you do that but for the sake of this example i'm not going to do a passphrase same passphrase again hit enter and now our key has been generated so here is our public key at this location now we can copy that and we're going to use the cat command to look at the contents of that file so cat and then that path dot ssh idrc.pub hit enter and this is what my public key looks like so i'm going to pretty much copy this entire thing minimize this and paste that right into there i'm going to call this you can call it whatever you want i'm going to call mine macbook pro and i'm going to add that ssh key to my digitalocean account now the one thing that i mentioned also is that there's a public and a private key so that is my public key my private key is right here okay so this is something that you never want to show anybody you always just want to keep it on your computer don't don't copy and paste that one up to digitalocean the one that you only want to share is the publicly public key not the private key so we won't look at that we will look at this one okay so that key has been added to our digitalocean account and now we can either associate that with the droplet or not so i'm going to do that because that's what the tutorial is about and then we're going to create this droplet so that's going to go ahead and instantiate the droplet takes 20 seconds so we'll fast forward through that okay and that droplet has been created with this ip address right here so i will copy that and here is where the magic happens so now we can go ahead and ssh into this droplet with ssh root at the ip address and typically at this point you would be prompted for a password but because we have that the ssh key associated with this droplet we won't have to do that and we'll just be logged directly into our ubuntu server so let's go ahead and try it out hit enter first time only it'll ask you about trusting the connection you can go ahead and type yes and bam we are in ubuntu this is uh our ubuntu droplet with the one cpu core two gigabytes of ram in the new york city data center so we'll exit out of that and just for another test let's go ahead and ssh in no user interaction here no password typing we're back into the ubuntu server now this any future droplets that you create you can associate that same ssh key with so we can come create a droplet and from this point forward you will always have that option unless you delete it from your account to log in via ssh with that public key that you created so if you want to learn more about ssh or digitalocean i have a whole bunch of other videos on my channel about that so i recommend that you check those out thank you guys for watching subscribe for more videos like this from me in the future and if you do i'll see you in the next one [Music] you
Info
Channel: Tony Teaches Tech
Views: 30,338
Rating: undefined out of 5
Keywords: digitalocean password ssh, digitalocean ssh key, digitalocean ssh, digitalocean add ssh key, add ssh key to digitalocean droplet, add ssh key digitalocean droplet, digitalocean ssh ubuntu, digitalocean ubuntu ssh, add new ssh key to digitalocean droplet, create ssh key for digitalocean, digitalocean add ssh key to droplet, digitalocean ssh key authentication, digitalocean ssh login, digitalocean login with ssh key, digitalocean ssh key login
Id: r3t61OP5mWs
Channel Id: undefined
Length: 5min 31sec (331 seconds)
Published: Tue Nov 02 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.