SSH Key Magic 💻🔑

SSH Key Authentication on Linux Server: Easy Setup Tutorial

Estimated read time: 1:20

    Learn to use AI like a Pro

    Get the latest AI workflows to boost your productivity and business performance, delivered weekly by expert consultants. Enjoy step-by-step guides, weekly Q&A sessions, and full access to our AI workflow archive.

    Canva Logo
    Claude AI Logo
    Google Gemini Logo
    HeyGen Logo
    Hugging Face Logo
    Microsoft Logo
    OpenAI Logo
    Zapier Logo
    Canva Logo
    Claude AI Logo
    Google Gemini Logo
    HeyGen Logo
    Hugging Face Logo
    Microsoft Logo
    OpenAI Logo
    Zapier Logo

    Summary

    In this tutorial by NeuralNine, learn the ins and outs of setting up SSH key authentication on a Linux server. The video guides you step-by-step on how to replace password-based authentication with SSH keys, enhancing your server's security. Whether using a rented online server, a virtual machine, or a computer on your local network, the process remains straightforward: generating a key pair, uploading the public key to your server, and configuring SSH settings to connect seamlessly without a password. The tutorial also includes advanced tips like creating configuration aliases for easier access.

      Highlights

      • Learn how to generate SSH keys to enhance server security! 🔒
      • Use easy command-line tricks with 'ssh-keygen' and 'scp' for key setup. 🛠️
      • Effortlessly upload your public key to any server with various options! 🌐
      • Multipass makes managing virtual instances straightforward and fun! 🖥️
      • Boost your SSH flexibility by customizing your 'authorized_keys' file. 🗂️
      • Set up aliases in your SSH config file for a smooth connection experience! 🎉
      • Say goodbye to passwords and hello to secure, key-based authentication! 🔐

      Key Takeaways

      • 🍀 Easily improve your server security with SSH key authentication, replacing passwords!
      • 🔑 SSH keys consist of a public and private key pair, where the private key is your secret weapon!
      • 🌍 The public key can be shared widely, acting as a verification tool on your server.
      • 🛠️ Create SSH keys using simple terminal commands like 'ssh-keygen.'
      • ✨ Use tools like SCP or Multipass to transfer your public key to the server.
      • 🚪 Append your public key to 'authorized_keys' for seamless login access.
      • 📁 Customize your SSH config for quicker server access with aliases.
      • 🔧 Multipass and SCP make managing virtual and remote servers a breeze!

      Overview

      Getting bored of constantly typing passwords? NeuralNine has you covered with this engaging guide to setting up SSH keys for server authentication. Unleash the power of SSH keys by creating a unique pair of keys—a public one for verification and a private one to keep under wraps.

        With just a few command-line dances, like 'ssh-keygen' for key generation and 'scp' for public key transfer, you'll turn your server into a fortress with minimal effort. This tutorial simplifies it all, whether you're working on a local network, virtual machine, or rented server.

          Fancy cutting out tedious steps? Customize your SSH config for blazingly fast server access. Turn simple commands into robust authentication processes, letting you job-hop servers like a pro. Dive into the magic of SSH key setups and banish password annoyances for good!

            Chapters

            • 00:00 - 00:30: Introduction to SSH Key Authentication In the video, the host introduces SSH key authentication, explaining its purpose and how to configure it on a server. The focus is on enabling authentication using a private key instead of a password, streamlining the process for secure server connections. The tutorial promises a step-by-step approach to setting up and using SSH key authentication.
            • 00:30 - 01:00: Requirements and Key Concepts This chapter discusses the requirements and key concepts needed for setting up a server to secure communications. It mentions the flexibility of choosing any form of server, whether it's a virtual machine on your computer, a computer within your local network, or a rented online server. A brief reference to a tool called 'multipass', which was covered in a previous video, is also made. The fundamental task is to generate a key pair (comprising a private key and a public key) on the server to establish authentication, with the public key being an essential component shared openly for verifying identity.
            • 01:00 - 02:00: Generating SSH Key Pair This chapter explains the concept of generating an SSH key pair. It highlights the difference between a public and private key, emphasizing that the public key is public information that can be shared widely, whereas the private key is secret and should be kept secure. The public key is used to verify your identity, while the private key proves you are the owner of the associated public key.
            • 02:00 - 03:30: Transferring Public Key to Server This chapter describes the process of transferring a public key to a server, emphasizing the importance of having the correct key for establishing a connection. It starts with a guide on opening the terminal and creating a key pair using the 'ssh keygen' command, or reusing an existing key if available. The chapter also mentions organizing keys by creating a new directory, referred to as the 'key directory,' where the keys will be generated and stored.
            • 03:30 - 05:30: Authorizing SSH Key on Server This chapter covers the process of authorizing an SSH key on a server. It explains how to create a connection key and the option to secure this key with a passphrase. The author decides not to use a passphrase in this particular video to keep things simple. The key points are the creation of a key and understanding the option to protect it with a passphrase, which would require the user to provide a password to use the key. The chapter ends with the author referencing two files generated in the process, although the reference to 'my connection key. poop' appears to be a transcription error or placeholder.
            • 05:30 - 06:30: Connecting to Server using Private Key The video discusses how to connect to a server using a private key. It explains the importance of placing the public key on the server, which allows the server to verify the connection from the corresponding private key, thereby ensuring it comes from the correct person or entity. This process involves using multipass or any SSH connection method. The speaker also mentions SCP, a tool for secure file transfer, which was covered in another video.
            • 06:30 - 08:00: Using SSH Config File The chapter titled 'Using SSH Config File' discusses various methods to transfer a public key to a server for SSH access. It mentions that you can upload the key using FTP, load it onto a website and download it from the server, or use SCP if there's an existing connection. Additionally, it explains the use of 'multipass transfer' command for doing this with virtual machines managed by Multipass.
            • 08:00 - 08:30: Conclusion and Call to Action In this chapter, the process of creating and using a multipass instance is explained. The steps include launching a multipass instance with a specific name and transferring files or keys to it. The example highlights transferring a connection key from a local directory to the multipass instance. This demonstrates a practical application of setting up and managing virtual environments effectively.

            SSH Key Authentication on Linux Server: Easy Setup Tutorial Transcription

            • 00:00 - 00:30 what is going on guys welcome back in this video today we're going to learn how to set up SSH key authentication on a server and how to then connect to the server using a private key and not a password so let us get right into [Music] ited all right so we're going to learn how to set up SSH key authentication on a server in this video today which means that we're going to be able to authenticate ourselves using a private key rather than a password and and the
            • 00:30 - 01:00 only thing that you need for this video is some sort of server that you can use you can use a virtual machine on your computer you can use uh any other computer in your local network if you have one uh you can use a server that you rented online you can use multipass which I recently made a video on it doesn't really matter you just need some server uh where you can set up the authentication so where you can put the public key so the idea is we're going to generate a key pair a private key and a public key and the public key is like uh the public information that everyone can have that is um what is needed to check
            • 01:00 - 01:30 if something is you if some key belongs to you or not so the public key is public information you can put it on a website you can put it on Twitter it doesn't matter everyone can have it uh and it's actually good if people have it because then they can authenticate or that they can check if you are the person trying to connect and the private key is secret information that only you have and it's the only thing that is going to um to to authenticate you as the person that the public key belongs to so the public key is like a checking tool tool and the private key is the
            • 01:30 - 02:00 thing that the checking tool is going to recognize as being the correct thing that allows for uh the connection so that's the basic idea and what we're going to do first is we're going to open up the terminal and create such a key pair if you don't have one you can also reuse an existing one if you have one uh and I'm going to create here a new directory let's call it key directory doesn't really matter uh and in this directory here I'm going to generate a key pair SSH key gen is the command uh and then I can do uh I can
            • 02:00 - 02:30 provide a path so I'm going to call this now my uh my connection key and uh then I can use a passphrase if I want to so I can uh secure this with a passphrase I'm going to leave this empty for this video uh the only thing that happens here is that if you provide a passphrase in order to be able to use the key you need to provide a password so you can protect it like that I'm going to just leave that uh empty for the sake of this video and then I get two things I get the my connection key and the my connection key. poop and
            • 02:30 - 03:00 this is the public key you need to somehow get this onto the server to signal to the server that this is the corresponding key uh to some private key that the server of course doesn't know but this is the um corresponding key which is going to allow you to check if the connection is coming from the correct person from the correct key um so for this video what I'm going to do is I'm going to use multipass again again it doesn't matter what you use you can just connect to your server using SSH and use SCP which I also made a video about recently to get your public
            • 03:00 - 03:30 key onto the server you can use FTP you can also put your key on a website and then go to the server and download it from the website it doesn't really matter you just need to somehow get your public key onto the server and this can be done using SCP if you already have a connection uh again I have a video on this or in the case of multipass if you want to do this on a virtual machine here you can just use the command multipass transfer which is just going to transfer the file using the multipass command so uh multipass list in my case is already a machine here again all you
            • 03:30 - 04:00 have to do to create a multipass instance if you don't have one is multipass launch and uh then a name so D- name and some name um and in my case now I'm going to just use the existing one so multipass transfer and uh then I'm going to use the path to this directory here so home uh neural 9 desktop key directory and I'm going to upload the public key so connection key. poop and this is
            • 04:00 - 04:30 going to be uploaded to some name which is the machine so the name of the virtual machine here and I'm going to upload this to home BTU because that's default user here and then SSH if the directory doesn't exist you have to create it in the case of root it's just root sl. SSH uh and again this is just the way I did it for the video it doesn't matter how you do it you can also connect to the server and do a w get command to download it from somewhere you just have to get somehow this key onto the server into the SSH
            • 04:30 - 05:00 directory uh and then you need to also connect to the server for example using a password or by already being physically present at the server maybe you have a keyboard there uh or by doing anything else that get gets you a connection to the server in my case it's a multipass shell command um on some name and now I'm on the server so the two things again I repeat what you have to do is you have to connect to the server somehow and you have to upload your key to the SS H directory here so
            • 05:00 - 05:30 in my case now you can see I have the my connection key. poop file on the server and all I have to do now to authenticate this or to authorize this key is I have to say cat my connection key so read the content in this case it just reads the content and then two angle brackets two closing angle brackets or greater than signs uh and I want to write this to the authorized Keys file so I get the content of this and I append it to the authorized Keys file it's very important that you use two angle brackets not one
            • 05:30 - 06:00 because otherwise you're just overwriting all the authorized Keys you want to use two to append the key to the already existing Keys uh and of course create this file if it doesn't exist so just run this command and then we can just exit and what I can do now is I can connect using SSH so I can say SSH and then um just Ubuntu add or actually I need dip address so multipass list uh I want to connect to this IP address so bu want to add
            • 06:00 - 06:30 10.3.1 18166 in this case now it's not going to work because I don't have a public key but if I provide dasi and then my connection key which is the private key then this is going to allow me to connect to the server without a password without anything and I can also of course copy this connection so I can um copy this key so I can copy the private key uh to my user directory. SSH and I I can do the same thing
            • 06:30 - 07:00 actually with the uh public key so like this um and I'm not sure if I have to restart my shell but then I can or I should be able to just say multipass uh list to get the IP address and then SSH and then one to at 10.3.1 18166 and this connects me automatically because it recognizes the key in my SSH directory uh that's the basic idea here now I can take this one step further and
            • 07:00 - 07:30 add a configuration to my uh known hosts file uh I think that's the that's the correct file uh or actually it's the config SSH file I think uh so we need to go to SSH and here I have the config file so if I go into config there are a couple of things that I have to censor here um but what you see here is I have a bunch of hosts to find and what I can do now is I can add a new entry so let me just resize this a little bit um I'm going to add here host
            • 07:30 - 08:00 and I'm going to call this local Das Ubuntu and then I'm going to say the user that I want to use for the connection is buntu and the host name is the IP address so just run a multipass list again copy this IP address here and then just pass it here and that is basically it so I can then close this clear uh exit rerun this and then I should be able to just say SSH local a bunch to and there you go it connects me
            • 08:00 - 08:30 to the server because now I have an alias in my config so this is how you can easily set up uh SSH key authorization on a server so that's it for today's video I hope you enjoyed it and hope you learned something if so let me know by hitting a like button and leave a comment in the comment section down below and of course don't forget to subscribe to this Channel and hit the notification Bell to not miss a single future video for free other than that thank you much for watching see you in the next video and bye for