Self Host 101 - Set up and Secure Your Own Server

Sdílet
Vložit
  • čas přidán 2. 06. 2024
  • In this video, CJ shows you how to configure and lock-down a Virtual Private Server running Ubuntu 22.04. With this base VPS setup, you can begin hosting your own apps and services. This is the first part in a series on self hosting.
    00:00 Intro
    00:59 The What and Why of Virtual Private Servers
    03:22 Connect to your VPS with SSH
    05:14 Update package lists and Upgrade packages
    09:16 Change root password
    09:56 Create non-root user
    13:08 Login with SSH Key
    15:19 Disable Password Login
    17:36 Disable root login
    18:25 Network and Firewall Policy
    19:11 Closed unused ports
    20:15 Change default SSH port
    21:31 Restrict port access to a specific IP
    22:29 Enable and configure automatic updates
    24:38 Thanks!
    ------------------------------------------------------------------------------
    Listen to Syntax episode 615 - syntax.fm/show/615/where-shou...
    Watch Syntax episode 730 - • Host your own Vercel
    Listen to Syntax episode 730 - syntax.fm/show/730/own-your-o...
    Github - generate an SSH key - docs.github.com/en/authentica...
    XKCD 149 - xkcd.com/149/
    unattended-upgrades reference - github.com/mvo5/unattended-up...
    ------------------------------------------------------------------------------
    Terms and Topics Covered:
    Terminal Emulator - en.wikipedia.org/wiki/Termina...
    SSH - Secure Shell - en.wikipedia.org/wiki/Secure_...
    VPS - Virtual Private Server - en.wikipedia.org/wiki/Virtual...
    Brute Force Attack - en.wikipedia.org/wiki/Brute-f...
    Exploit - en.wikipedia.org/wiki/Exploit...)
    Vulnerability - en.wikipedia.org/wiki/Vulnera...)
    Self Hosting - en.wikipedia.org/wiki/Self-ho...)
    Media Server - en.wikipedia.org/wiki/Media_s...
    PaaS - Platform as a service - en.wikipedia.org/wiki/Platfor...
    Ubuntu - en.wikipedia.org/wiki/Ubuntu
    Debian - en.wikipedia.org/wiki/Debian
    Principle of least privilege - en.wikipedia.org/wiki/Princip...
    Superuser - en.wikipedia.org/wiki/Superuser
    sudo - en.wikipedia.org/wiki/Sudo
    Public-key cryptography - en.wikipedia.org/wiki/Public-...
    gnu Nano - en.wikipedia.org/wiki/GNU_nano
    port Computer Networking - en.wikipedia.org/wiki/Port_(c...)
    Firewall - en.wikipedia.org/wiki/Firewal...)
    ------------------------------------------------------------------------------
    Self Host-able Services Mentioned:
    Awesome Selfhosted - github.com/awesome-selfhosted...
    Media Servers
    Plex - www.plex.tv/
    Jellyfin - jellyfin.org/
    Emby - emby.media/
    File Sharing
    Nextcloud - nextcloud.com/
    Password Managers
    Bitwarden - bitwarden.com/blog/host-your-...
    Passbolt - www.passbolt.com/self-hosted-...
    Error Tracking / Monitoring
    Sentry - develop.sentry.dev/self-hosted/
    ------------------------------------------------------------------------------
    Self Host-able PaaS Mentioned:
    piku - github.com/piku/piku
    dokku - dokku.com/
    kubero - github.com/kubero-dev/kubero
    caprover - caprover.com/
    coolify - coolify.io/
    ------------------------------------------------------------------------------
    Paas - Platform as a Service Mentioned:
    Vercel - vercel.com/
    Netlify - www.netlify.com/
    Heroku - www.heroku.com/
    fly.io - fly.io/
    Render - render.com/
    Railway - railway.app/
    ------------------------------------------------------------------------------
    Hosted Database Providers Mentioned:
    AWS RDS - aws.amazon.com/rds/
    PlanetScale - planetscale.com/
    Neon - neon.tech/
    ------------------------------------------------------------------------------
    Hit us up on Socials!
    www.syntax.fm/links
    Brought to you by Sentry - Use code "tastytreats" to get 2 months free - sentry.io/syntax
    #vps #ubuntu #selfhosted #guide
  • Věda a technologie

Komentáře • 108

  • @syntaxfm
    @syntaxfm  Před 2 měsíci +21

    This video is for beginners and hobbyist that are learning about the basics of servers and Linux. If you are managing multiple servers you can automate this kind of setup with tools like Terraform, Ansible, Puppet, Chef and others. We hope to cover these kinds of tools in future videos.
    Also, we want this video to be an accurate and secure guide for people that are learning the basics, if you notice anything wrong or missing, please let us know and we will add corrections.

  • @WesBos
    @WesBos Před 2 měsíci +33

    CJ on fire with these videos! 🔥🔥🔥

    • @nickdhrones6425
      @nickdhrones6425 Před 2 měsíci +2

      I sure hope CJ's being properly compensated? He's a real catch!
      You guys have always been entertaining and great to watch! But, CJ is so high-bandwidth while also very entertaining. I love to be entertained while being educated. Syntax now is best in class on CZcams!!!

  • @_techbk
    @_techbk Před 2 měsíci +2

    Love this !! so easy to understand and follow !! That SSH ports explanation was top notch

  • @chrisliva6841
    @chrisliva6841 Před 2 měsíci

    Great video CJ, looking forward to the series!

  • @kyrregjerstad
    @kyrregjerstad Před 2 měsíci

    Looking forward to the next part of this series! Just signed up for a Hetnzer VPS and followed the steps here, I now know so much more about basic linux and web servers!

  • @somyaranjan26
    @somyaranjan26 Před 2 měsíci +1

    Excited about the future content for setting the server for web apps

  • @poloat
    @poloat Před 2 měsíci +6

    I have always loved CJ and his tutorials on his channel, but he hasn‘t done them often in the last months I think. More CJ tutorials!!!

    • @syntaxfm
      @syntaxfm  Před 2 měsíci +3

      Once we get rolling there will be much more CJ on this channel

    • @alexdin1565
      @alexdin1565 Před 2 měsíci

      can you share his channel link

    • @poloat
      @poloat Před 2 měsíci

      @@alexdin1565 youtube.com/@CodingGarden

    • @poloat
      @poloat Před 2 měsíci

      @@alexdin1565 CodingGarden on yt

  • @nickdhrones6425
    @nickdhrones6425 Před 2 měsíci

    What a catch CJ was. I thoroughly enjoy his style and energy!

  • @andybourgeoisinfo
    @andybourgeoisinfo Před 2 měsíci

    New favorite channel! These videos are so good.

  • @SRG-Learn-Code
    @SRG-Learn-Code Před 2 měsíci

    So goooooood...
    VPS FTW! I'm hyped about this series! Thanks for sharing! CJ you are the MVP(S) 😘

  • @DRTYDR3Y
    @DRTYDR3Y Před 2 měsíci

    Absolutely love your content. Can’t explain it, but it feels like I’m being tutored 1 on 1. You have a knack for teaching. Stoked for more!

  • @talensjr
    @talensjr Před 2 měsíci

    Super useful series!! Keep it going 😃

  • @KaizenCodes
    @KaizenCodes Před 2 měsíci

    This video brings me happiness. Not just the content, but CJ is the best fit for this by a mile!

  • @bluetheredpanda
    @bluetheredpanda Před 2 měsíci

    That is some GREAT content. Can’t wait for the next parts of this series

  • @nekoill
    @nekoill Před 2 měsíci

    Heyyy CDawg, didn't know you had another channel, my guy! Most instantest sub ever 😸

  • @isaacdruin
    @isaacdruin Před 2 měsíci

    Ohhh. This is awesome. I have a PC that I've been thinking about utilizing like this. I will be following this series for sure!

  • @samirergaibi874
    @samirergaibi874 Před 2 měsíci

    Great stuff, looking forward to the next one!

  •  Před 2 měsíci +4

    Excited for this series! Would be interested to see server configuration with Caddy

  • @mamadj359
    @mamadj359 Před 2 měsíci

    Thank you. I really needed this. It explained everything plain and simple.

  • @chatka92
    @chatka92 Před 2 měsíci

    That was very interesting and useful. Please keep it coming.

  • @dav1dw
    @dav1dw Před 2 měsíci

    I've been using Linux for 6 months, but learned a lot of new things. Great video!

  • @dbaphomet
    @dbaphomet Před 2 měsíci

    CJ is a beast. I definitely love these how to video's and self hosted is what I'm working on.

  • @TheLilthy
    @TheLilthy Před 2 měsíci

    Great video, helps a lot, CJ!

  • @carsonhartley8125
    @carsonhartley8125 Před 2 měsíci

    This is on the outer edges of the theoretical limits of how good CZcams content can be. Great job!!

  • @jacobshore
    @jacobshore Před 2 měsíci

    I'm liking the shift to Linux stuff and servers!! Looking forward to more.

  • @mrevergreen9049
    @mrevergreen9049 Před 2 měsíci

    Wow this is amazing cj
    just in time
    Pleaaase continue I’m excited for this series 🔥🔥
    Coding garden forever 🌱

  • @scottfwalter
    @scottfwalter Před 2 měsíci

    Seriously this video helped me immensely. I just have a little play server and didn't realize anyone would try to hack into it. Sure enough, I checked the auth log and there's a lot of activity of some folks trying to log in with all sorts of usernames. My server is now secure thanks to the info in this video.

  • @ravenbergdev
    @ravenbergdev Před 2 měsíci

    Love this content. It's actually worth learning this stuff as opposed to the latest in js-land.

  • @Pra2wins
    @Pra2wins Před 2 měsíci

    Very useful, thanks CJ ❤

  • @slicerabbit6166
    @slicerabbit6166 Před 2 měsíci

    syntax is looking good on you, CJ!

  • @keshav1598
    @keshav1598 Před 2 měsíci

    super interested , keep them videos coming

  • @mj2068
    @mj2068 Před měsícem

    this is a really really good video. sshing my love to you... ❤

  • @kristiankubis640
    @kristiankubis640 Před 2 měsíci

    Man, if I had this video when first setting up my Raspberry Pi I would be over the moon 🙌. Having to figure all this stuff out separately took some time.

  • @tiagosutter8821
    @tiagosutter8821 Před 2 měsíci

    Great stuff, thanks for the content!

  • @rafaeldemacedo
    @rafaeldemacedo Před 2 měsíci

    That was just what I was looking for!

  • @jitx2797
    @jitx2797 Před 2 měsíci

    Oh wow perfect. I have just started self hosting my stuff and I know little about security. Thanks Coding Garden Guy

  • @josephgay-cj2fc
    @josephgay-cj2fc Před 2 měsíci

    Can't wait for part 2

  • @0xshaheen
    @0xshaheen Před 2 měsíci

    Great content as always cj, but I got dizzy from the zooming in and out❤😂

  • @Fullflexno
    @Fullflexno Před 2 měsíci

    CJ! Love it !

  • @JuanMoisesTorrijos
    @JuanMoisesTorrijos Před 2 měsíci

    Awesome! Let's go!

  • @Supadiri
    @Supadiri Před 2 měsíci +8

    Great content CJ! One little advice from a viewer perspective, please limit the amount of zoom in/zoom out for the framing. A more subtle movement would be beneficial and still effective! Thanks!

    • @syntaxfm
      @syntaxfm  Před 2 měsíci

      Thanks for the feedback. This does stop after the 3 minute mark, but I should probably limit it to just the intro. -CJ

    • @Supadiri
      @Supadiri Před 2 měsíci

      @@syntaxfm You are right, I've just finished this great video and I've noticed the improvement in the subsequent minutes. Kudos and waiting for the next!

  • @ayazsayyed9053
    @ayazsayyed9053 Před 2 měsíci

    I really really want part 2 CJ

  • @jacobwerner8533
    @jacobwerner8533 Před 3 dny

    this is a great video.

  • @fullstack_journey
    @fullstack_journey Před 2 měsíci

    Ayye seeing your face instantly lit up my face with a smile

  • @juanmacias5922
    @juanmacias5922 Před 2 měsíci

    2:54 I've been wondering how much a tiny/starter VPS could handle, thanks for the info!

  • @alejandroyanes391
    @alejandroyanes391 Před 2 měsíci

    pretty cooool !😱

  • @MyrLin8
    @MyrLin8 Před 2 měsíci

    Nice :) thanks.

  • @codeman99-dev
    @codeman99-dev Před 2 měsíci +1

    21:19 Just add the custom port number to your (client) ssh config! Super easy win. I specify my user there too because I typically only have a single user I'm concerned with.

  • @moddeht
    @moddeht Před 2 měsíci

    This is amazing

  • @philsola
    @philsola Před 2 měsíci

    This is a great video for walking through VPS basic set up and security measures. Really enjoyed it! Looking forward to the next one 👌
    One question for my own understanding, we do something similar already with SSH keys at my day job, but we use .pem keys to log in. Is there any difference / benefits to doing it that way vs how you're doing it without?
    Thanks

    • @syntaxfm
      @syntaxfm  Před 2 měsíci +1

      .pem is a container file format that can store all kinds of cryptographic keys including SSL certificates. When using it with SSH, it will contain a private key.
      The ~/.ssh/id_rsa (private key) file is actually a .pem file but without the extension!
      The only difference with the way you are connecting is manually specifying the key to use instead of the ssh agent picking one automatically from ~/.ssh - if you want the ssh-agent to automatically use your .pem file when connecting to a server, you can use: ssh-add keyfile.pem - but you'll need to do this after every reboot.
      -CJ

    • @philsola
      @philsola Před 2 měsíci

      @@syntaxfm Awesome thanks CJ! Great video

  • @ralacerda12
    @ralacerda12 Před 2 měsíci

    Nice video! This video will be a great checklist for when I'm spinning up a new VPS.
    My question is, how much can you pack inside this 1 vCPU 1GB Ram VPS?
    Will it be able to run an simple sqlite database + nuxt?
    Any tips on how to make the most out of it?

  • @prashlovessamosa
    @prashlovessamosa Před 2 měsíci

    Thanks CJ

  • @remccs16
    @remccs16 Před 2 měsíci

    This kind of stuff interests me!

    • @joaquimley
      @joaquimley Před 2 měsíci

      Also saying in the comments.

    • @HumanoAI
      @HumanoAI Před 2 měsíci

      Are you sure you wouldn’t rather hear how a famous dev guy or other, starts his day, and what kinda coffee he drinks? syntax sometimes goes on two hour interviews of non value info. I agree I like this better. Syntax keep up the channel…

    • @syntaxfm
      @syntaxfm  Před 2 měsíci

      The goal here is to have regular deep dives into real code and practical stuff to accompany the more causal pod. Def more on the way.

  • @blakenator123
    @blakenator123 Před 2 měsíci +1

    Thanks for the awesome content, so much information and you really find a great balance between depth and speed.
    I have a spare dell laptop lying around which I am beginning to think to turn into my own server. How deluded am I?
    The main purpose would be for my business to run a python script for langchain that takes a recording, transcribes it and then saves to to a git repo (an automatic summary for students).
    The reason being I am having a hard time making the script and corresponding packages easy to install and set up for my peers! So I want to set the laptop up as a kind of server, albeit with some down time now and then.

    • @syntaxfm
      @syntaxfm  Před 2 měsíci +1

      A spare old laptop running Linux is a great way to get started with this kind of stuff as well. If you haven't heard of it, research "home lab" and you'll find lots of resources on this. I think if the server will only be used by students / staff, this should be doable. -CJ

    • @blakenator123
      @blakenator123 Před 2 měsíci

      @@syntaxfm thanks, that's what I really wanted to hear haha

  • @krisclem8290
    @krisclem8290 Před 2 měsíci

    Can't you use scp to copy your public key to your vps? There is also a way to add 2FA using TOTP codes as a second form of authentication to the terminal.

  • @alexdin1565
    @alexdin1565 Před 2 měsíci

    this is my first time i like the youtube suggestion very clear tutorial and I like you energie thanks CJ
    please can you add this tutorials
    how we can run docker apps in vps and use different domain name for each app ?
    run Nginx as reverse proxy

  • @codeman99-dev
    @codeman99-dev Před 2 měsíci

    4:30 Maybe I missed it, but the reason for the fingerprint is to help prevent "man in the middle" attacks.

  • @qubitgg
    @qubitgg Před 2 měsíci

    Yesss! **Grabs Popcorn**

  • @tmxwll
    @tmxwll Před 2 měsíci

    CJ ❤

  • @user-on2rx4si7g
    @user-on2rx4si7g Před 2 měsíci

    If I don't have my machine where I log in with my secondary user, how can I log in to the server if the root is disabled as well?

  • @BrickTamlandOfficial
    @BrickTamlandOfficial Před 2 měsíci

    the auth.log command didnt work for me because there was no file. but i used last and lastlog which works fine.

  • @nicobaier5424
    @nicobaier5424 Před 5 dny

    What provider are you using for your VPS? I've always been overwhelmed trying to choose

  • @LauriePoulter
    @LauriePoulter Před měsícem

    Given these tasks are always performed when setting up a VPS is there a way to automate them?

    • @syntaxfm
      @syntaxfm  Před měsícem

      Yes there are a few popular tools for this: cloud-init, Terraform, Ansible, Puppet and Chef
      -CJ

  • @belkocik
    @belkocik Před 2 měsíci

    Are you going to cover cloudflare?

  • @azteck2
    @azteck2 Před 2 měsíci

    How can you use something like Zerotier or Tailscale to only allow ssh from those vpn services?

    • @CodingGarden
      @CodingGarden Před 2 měsíci +1

      You can do this with those tools or any other type of VPN including OpenVPN and Wireguard. Once the VPS is connected to the VPN, you can add a firewall rule that limits connections to port 22 from a given subnet within the VPN.

    • @azteck2
      @azteck2 Před 2 měsíci

      @@CodingGarden Great, thanks!

  • @scottfwalter
    @scottfwalter Před 2 měsíci +1

    What happens if you disable password login and lose your public key?

    • @syntaxfm
      @syntaxfm  Před 2 měsíci +2

      If your VPS provider has "console" mode, you can login with the root password if you still know it. In some cases this would require a support ticket / someone at the VPS company with direct hypervisor access to login. Otherwise, you would need to ask your hosting provider to reset your VPS. This is why backups and fail safes are important. I'll talk about those in future videos. -CJ

  • @nickwoodward819
    @nickwoodward819 Před 2 měsíci

    Yup, after realising there's no good way to prevent unexpected serverless costs i've gone back to traditional servers.

  • @yammerttv
    @yammerttv Před 2 měsíci

    Hey it seems your audio is slightly out of sync with the video itself.

  • @twitchizle
    @twitchizle Před 2 měsíci

    Kool kool kool

  • @plaintext7288
    @plaintext7288 Před 2 měsíci

    Guys, this might not be the best place to ask question, but I am wondering rn how can i publish my portfolio app that makes uses websockets for free? Looking at servicea other than aws, azure, gcp feels like some functionality is missing while they themselves look like rabbitholes😅

    • @WesBos
      @WesBos Před 2 měsíci +1

      websockets require a traditional long-running server, and I don't think there are any free offerings in this space. You should grab a $5 VPS and follow along this series so you can host your own :)

    • @CodingGarden
      @CodingGarden Před 2 měsíci

      I linked a few cheap VPS options here: twitter.com/coding_garden/status/1770834001843957963
      Another alternative for real-time connections is to use the free tier on a hosted service like supabase or firebase, but this will likely require you to re-write your real-time logic.

    • @plaintext7288
      @plaintext7288 Před 2 měsíci

      @@WesBos @CodingGen thank you! I will look into these

  • @Emadmohamad
    @Emadmohamad Před 2 měsíci +1

    Does CJ has his own channel?

    • @CodingGarden
      @CodingGarden Před 2 měsíci +1

      I do! Over here on Coding Garden. I haven't posted any videos there since joining Syntax but will start live streaming again soon.

  • @handerson171
    @handerson171 Před 2 měsíci

    Cant seem to find find episode 615 of syntax...

    • @syntaxfm
      @syntaxfm  Před 2 měsíci

      syntax.fm/show/615/where-should-you-host-your-app-hosting-providers-compared

  • @badriinfo259
    @badriinfo259 Před 2 měsíci

    How to get public ip

  • @cipherw0lf
    @cipherw0lf Před 2 měsíci

    Has the channel been renamed?

    • @syntaxfm
      @syntaxfm  Před 2 měsíci +1

      It has. Check out this for the full story czcams.com/video/fmdJ1KGSKIA/video.htmlsi=LEMCXbW0a8VIi9Oj
      TLDR, Level Up Tutorials and Syntax were acquired by Sentry and to simplify things we combined them. Scott who started LUT is deeply involved in content and planning.

  • @janviehweger
    @janviehweger Před měsícem

    Don't forget to set correct file permissions!
    chmod 700 ~/.ssh
    chmod 600 ~/.ssh/authorized_keys