How to Create & Add SSH Keys on Any OS | Secure Your VPS

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
are you tired of having to type out your VPS password every single time if so you're not alone in this video I'll tell you all about SSH keys and how to set them up fast and easy on any operating system let's go generally people log into their VPS environments with the tried ENT username and password combo while this will work just fine for most it can be extremely vulnerable to Brute Force attacks what's more the process can be made much more efficient this is where SS steps in offering both security and convenience SSH Keys utilize public key cryptography a system more robust than passwords let's briefly go over how it all works the SSH protocol utilizes two keys a private key and a public key think of the private key as your secret digital signature which is kept secure on your local computer the public key on the other hand is designed to operate out in the open you would add it to your VPS environment like a digital lock in essence anyone can use your public key to encrypt messages specifically for you but only your private key can decrypt them this ensures secure communication and protects your VPS from unauthorized access this also makes it so you don't need to enter a password every time you come connect which helps save a bit of time if all of this sounds great you will want to generate your first pair of public and private SSH keys after that I'll show you how to connect the public key to your VPS using H panel keep in mind that the steps to do all of this will differ based on your operating system but don't worry though as I'll be demonstrating how to do this for Linux Mac OS and windows you'll also need to run some commands in the terminal so head down below and check out our hosting your tutorials article which has all the necessary commands for you to copy but before we begin make sure to hit that subscribe button to see more VPS tips and tutorials like this all right let's Jump Right In starting with Linux and Mac OS there are two commonly used algorithms for generating authentication Keys RSA and ed25519 I'll call it Ed 25 for short an SSH RSA key is a previous industry standard while it's secure and reliable it's rapidly being replaced by ed25 ed25 is the newcomer coming in with a much smaller key size it's much more efficient and does not compromise on security either while the current trend is deprecating RSA and embracing ed25 as the new standard it's always best to check which one your seral will support FYI hostinger VPS supports both algorithms that being said the steps to generate the pair of keys are almost identical regardless of your choice I'm going to use ed25 as an example RSA will work just fine as well for both Linux and Mac OS access the terminal on your local computer and enter this command wait for the process to finish the key generator will ask you to choose a location to store the keys if you prefer to save them in different location just change the P then hit enter to save them in the location that you specified in the terminal next the key generator window will ask you to create an SSH key passphrase this will be used to access your private key you can press enter to skip the step but I highly recommend creating a private key passphrase this way if someone does manage to gain unauthorized access to your private key they won't be able to use it without the passphrase then just retype the key passphrase and enter again the SSH key gen command should also have created a public key and a private key in this specific path and file name the public key file in particular should have a pub extension now that you have generated the pair of keys within your desired directory the private key will stay nice and secure in your computer now you just need to connect the public key to your VPS you can find the time stamp for that in the description below as for now I'll be showing how to generate the keys in Windows to generate SSH keys on Windows you'll need to get both puty and puty gen installed on your computer if you don't already have putty you can find it quick and easy by just typing putty in your search bar as for puty Jen you can grab it on the official website you'll find the link in the description below once everything's ready start party Jen while you can adjust things like key length before the generation the default options will work just by simply hit generate to get your SSH key pair when the process bar starts loading give your mouse a workout by moving it around this will help the software generate a random pattern for your key once that's done your public SSH key will be displayed on the screen if you're going to use the key for the Linux based VPS make sure to copy the open SSH public key this is because Linux systems don't support the default party format then even though you can keep those boxes empty I highly recommend creating a pass phrase for your SSH private key doing so will add an extra layer of security to your server once done save your private key to any desired location on your computer name it anything you like now just repeat the process to save your public key to the same location and that's it the private key should stay on your computer while your public key needs to be uploaded to the server you wish to connect to we'll go over that in the the next section for now though you'll need to attach the private key to puty this way your server will recognize your computer when using putty to connect open putty and navigate to connection SSH O then choose credentials in the sidebar on the left browse for your private key file in this field select the private key file the one with the PPK extension and click open once that's done we can finally connect the public key to the remote server while the steps so far were different depending on the operating system connecting a public key to your VPS will depend on your hosting provider we're using hostinger VPS hosting and we can do everything super quick with the H panel all in just a single click you just need to open your public key file from the directory as a reminder it's the one with the pub file extension let's keep this window open while moving on to the new tab log into H panel and navigate to the VPS menu then pick a server go to settings SSH Keys now just click this button to add your SSH key a popup will appear asking you to give a name for where the sshh key is saved once that's done copy and paste the content of the pub file in the respective box finally hit add SSH key and that's it for assistance go to our knowledge base or cont contact our customer success team our VPS even includes a built-in AI assistant that can help you with any issues you might have if everything went smoothly you just set an SSH key and can access your server but what if you have multiple servers can you generate multiple SSH keys of course and it's even highly recommended continue watching for tips on managing multiple SSH keys as your projects grow and diversify you may find yourself using many SSH Keys all for different servers user accounts or projects if this occurs I highly recommend an SSH agent it will quietly run in the background and securely store any private Keys you might have not only that it will also let you manage SSH key pairs across multiple connections and even remember your private key passphrase within the same session if that's sounds good just launch your terminal or an SSH client like puty if you want with puty you'll also need to get pageant from their downloads page for this to work then enter this command to start the SSH agent next write the SSH add command to add your private key to the SSH Agent following the command add your private key file name if your private key is protected with a passphrase it will prompt you to enter it once that's done run this command to confirm that your private key has been added it will list the identities currently held by the agent and now you can connect to remote servers without entering your passphrase for each session simply use this command to log in now let's start wrapping things up with the best practices for managing your SSH key a lot of things can go wrong with SSH keys if you're not paying attention you could lose track of them or even worse get them compromised to avoid any of that make sure to have everything in order first disable password authentication use only private public key authentication as your main server login this way only authorized users can access the server via SSH once that's applied you need to ensure that SSH key storage is secured restrict access to your private keys by storing them in the protected area of your system if needed you can also set proper permissions using the C hod command update your private and public Keys regularly to reduce the likelihood of compromising your keys run the SSH key gen command regularly to create new keys and replace old ones also limit the key pair usage while you can use the same keys for different servers doing so is not safe if the private key gets lost it will compromise the security of all its Associated devices ensure that a single key pair is used used for one purpose only such as a specific project or user account this makes your keys easier to manage and isolates potential security risks practicing this means you can keep multiple SSH keys so there are more points to keep in mind organize your keys pairs neatly some of the best practices are clear naming conventions applying logical directory structures and maintaining proper permissions this way each SSH key p is easily identifiable use key aliases to help distinguish each key purpose or Associated project in fact during the key generation process you can add the comment with C flag to specify the Alias for instance like this then you can run the host name command to display the host name of the current system this helps ensure you select the appropriate key for the chosen host lastly adjust the SSH settings for specific hosts the SSH configuration file lets you define which SSH keys to use for certain hosts or domains this minimizes the risk of using the wrong key during the login process now that's how you set up SSH Keys how did it go for you leave your thoughts and questions in the comments below just don't post your private key if you found this video helpful don't forget to give it a like and share subscribe for more videos on BPS tips and tutorials like this and and turn on your notification so you won't miss our new videos every week thanks for watching and good luck on your online Journey
Info
Channel: Hostinger Academy
Views: 1,254
Rating: undefined out of 5
Keywords: ssh keygen, ssh keys, generate ssh key, private key, ssh key generation, generating ssh keys, how to create an ssh key, ssh key tutorial, ssh login, ssh login linux, ssh login mac, ssh key vps, vps, vps hosting, vps secure, how to secure vps, hostinger, hostinger vps hosting, private key generator software, putty, puttygen, rsa algorithm, ed25519 signature, ssh key windows, ssh private key, ssh keys tutorial, peagent.exe
Id: mdN3jKk2jg0
Channel Id: undefined
Length: 12min 16sec (736 seconds)
Published: Thu Apr 04 2024
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.