Linux Server Build: OpenVPN From Scratch - Hak5 2019

Поделиться
HTML-код
  • Опубликовано: 5 июл 2016
  • Hak5 -- Cyber Security Education, Inspiration, News & Community since 2005:
    ____________________________________________
    Today we're building an OpenVPN server from scratch in Linux!
    -------------------------------
    Shop: www.hakshop.com
    Support: / threatwire
    Subscribe: / hak5
    Our Site: www.hak5.org
    Contact Us: / hak5
    ------------------------------
    Install and setup OpenVPN
    apt-get update; apt-get install openvpn easy-rsa
    gunzip -c /usr/share/doc/openvpn/examples/sample-config-files/server.conf.gz /etc/openvpn/server.conf
    nano /etc/openvpn/server.conf
    replace dh1024.pem with dh2048.pem
    #uncomment push "redirect-gateway def1 bypass-dhcp"
    #uncomment push "dhcp-option DNS" and replace IP addresses with your fav DNS
    #uncomment user nobody
    #uncomment group nogroup
    #save and exit
    Setup Firewall
    #Enable IP forwarding
    echo 1 /proc/sys/net/ipv4/ip_forward
    nano /etc/sysctl.conf
    #uncomment net.ipv4.ip_forward=1
    #save and exit
    #Configure firewall.
    ufw status
    ufw allow ssh
    ufw allow 1194/udp
    #Let packets forward through the VPS by changing for forward policy to accept
    nano /etc/default/ufw
    #replace DROP with ACCEPT in DEFAULT_FORWARD_POLICY="DROP"
    #save and exit
    #Enable NAT and IP masquerading for clients
    nano /etc/ufw/before.rules
    #Add the following near the top
    *nat
    :POSTROUTING ACCEPT [0:0]
    -A POSTROUTING -s 10.8.0.0/8 -o eth0 -j MASQUERADE
    COMMIT
    ufw status
    Setup Keys and Start the Server
    cp -r /usr/share/easy-rsa/ /etc/openvpn
    mkdir /etc/openvpn/easy-rsa/keys
    nano /etc/openvpn/easy-rsa/vars
    #change export KEY_* values
    #set KEY_NAME to "server"
    #save and exit
    #Generate the 2048 bit Diffie-Hellman pem file we pointed to in the openvpn config
    openssl dhparam -out /etc/openvpn/dh2048.pem 2048
    #move to the easy-rsa directory
    cd /etc/openvpn/easy-rsa
    #Set the variables we configured
    . ./vars
    ./clean-all
    ./build-ca #Accept all defaults
    ./build-key-server server #Accept all defaults
    #Move the newly generated certificates to /etc/openvpn
    cp /etc/openvpn/easy-rsa/keys/server.crt,server.key,ca.crt /etc/openvpn
    #In /etc/openvpn we should have a server.conf, server.crt, server.key, ca.crt and dh2048.pem
    #start the OpenVPN service
    service openvpn start
    service openvpn status
    Setup keys for the first client
    ./build-key client
    ls keys
    #Make a new directory to merge the client configuration and keys
    mkdir ~/client
    #Copy the example client configuration renaming the file extension from conf to ovpn
    cp /usr/share/doc/openvpn/examples/sample-config-files/client.conf ~/client/pineapple.ovpn
    cd /etc/openvpn/easy-rsa/keys
    cp client.crt client.key client.ovpn ~/client
    cp /etc/openvpn/ca.crt ~/client
    Securely copy client.crt, client.key, ca.crt and client.ovpn to your client device
    cd ~/client
    #determine public IP address
    ifconfig
    nano pineapple.ovpn
    find remote and replace my-server-1 with IP address of VPN server
    uncomment group nogroup
    uncomment user nobody
    comment out the ca, cert and key directives
    save and exit
    echo "ca" to pineapple.ovpn
    cat ca.crt to pineapple.ovpn
    echo "/ca" to pineapple.ovpn
    echo "cert" to pineapple.ovpn
    cat client.crt to pineapple.ovpn
    echo "/cert" to pineapple.ovpn
    echo "key" to pineapple.ovpn
    cat client.key to pineapple.ovpn
    echo "/key" to pineapple.ovpn
    ~-~~-~~~-~~-~
    Please watch: "Bash Bunny Primer - Hak5 2225"
    • Bash Bunny Primer - Ha...
    ~-~~-~~~-~~-~
    ____________________________________________
    Founded in 2005, Hak5's mission is to advance the InfoSec industry. We do this through our award winning educational podcasts, leading pentest gear, and inclusive community - where all hackers belong.
  • НаукаНаука

Комментарии • 321

  • @qwarlockz8017
    @qwarlockz8017 5 лет назад +3

    This was a great run through. Thanks so much for making this pretty straight forward. This gave me what I did not have before. Going through docs and tutorials and the like it always had a LOT of extra. This was just a handbook on "Lets just make this work." You rock!

  • @devjock
    @devjock 8 лет назад +1

    Awesome episode, welcome back guys!
    Darren did a really good job of keeping a 50+ minute setup and operation video interesting. I bet this is going to help a lot of people! Setting things up on my Pi 3 right now!

  • @tonylock7657
    @tonylock7657 7 лет назад +2

    You guys rock. I just followed this video and set up an OpenVPN server on a Raspberry Pi on my home network. and it works. I must confess that I followed another of your vids about OpenVPS SA on a VPS, and that didn't work for me (I kept getting four different 10.x.x.x subnets, and the gateway at home (the Pi) and the client (a laptop) ended up on different subnets) , and the simplified script based setups out there in Internet Land didn't work for me either (I think it may have been routing issue). Anyway - it's working now. Great!
    Keeps up the good work.

  • @TheDIYer
    @TheDIYer 3 года назад

    i love the way you put everything you used in the description makes it easier to refer to

  • @KandMe1
    @KandMe1 4 года назад

    This is very good and well done. Just very thorough IMAO. Been researching this for some days now and this is the best I have come across so far.

  • @Derbauer
    @Derbauer 7 лет назад

    great show guys loved the detailed content and the long duration with comprehensive walk through. much appreciated.

  • @yasin7520
    @yasin7520 Год назад

    You are by far the best teacher for soft soft . It's very complicated at first - overwhelming, actually - but, you make it doable for

  • @doomgod314
    @doomgod314 5 лет назад

    I love my Pi, but i bought a refurbished HP ProLiant DL360 G7 for less than $200 off Amazon and this thing is a beast. I’m loading down every home service I need, from Plex-Media to DNS Blackhole. I’m looking forward to testing this OpenVPN install video when I get home tonight.
    Thanks Hak5. As always, your tutorials are second to none. Fun, detailed, and insightful in ways only seasoned veterans of the field can provide.

  • @pcastro3783
    @pcastro3783 7 лет назад

    Of all the effen tutorials, you guys got me up and running. Thank you!

  • @lordraiden8792
    @lordraiden8792 6 лет назад

    I just fixed my own Pi3-based OpenVPN box thanks to your tips about the firewall.
    Thank you very much!!

  • @JamieAlban
    @JamieAlban 6 лет назад

    This is the first of your vids I've watched - you guys are super fun, subscribed.

  • @geoffhalsey2184
    @geoffhalsey2184 7 лет назад

    Tried it out on a virtual machine first. Worked first time! Soon to be on my cloud server.
    Nice one guys!

  • @RobertGallop
    @RobertGallop 8 лет назад +72

    Yes vote for IPv6 episode in depth!

  • @suijurisinfowarrior
    @suijurisinfowarrior 8 лет назад

    Thanks Darren, I was pulling what little hair I have left trying to configure an OpenVPN server.
    Off to deploy this tech for my travels.
    Snubs, the mnemonic helps me where the wrong character can make you elated or deflated.

  • @Quinqx
    @Quinqx 8 лет назад

    Would love to see an in-depth IPv6 episode showing up! Keep up the good stuff! :)

  • @dawnS33ker
    @dawnS33ker 3 года назад

    an episode on ipv6 would be great. Thanks for the amazing video, guys.

  • @yuudai1400
    @yuudai1400 6 лет назад

    I'm a total hacking noob, but this was so much fun to watch. I'll get this running, and I'll also enjoy seeing your videos about raspberry pi and RF. Keep up the good work!

  • @pierredahmani4101
    @pierredahmani4101 3 года назад

    This tutorial helped me out so much, both of you are great. Thanks!

  • @Macadoof
    @Macadoof 7 лет назад +1

    You guys are lovely. Thank you for a great video, I learned a lot here.

  • @ChristopherDeVries
    @ChristopherDeVries 8 лет назад +1

    Fantastic tutorial guys. Thank you for making this video.

  • @talabaniinday213
    @talabaniinday213 Год назад

    Thanks for the kind words, I'm always happy to help! Let know if you'd like any videos on specific topics in the future. I wish you all the

  • @MrSimonsmoke
    @MrSimonsmoke 7 лет назад

    Thanks for the tutorial , now I get the server running on my Rpi ! Feel for u guys and keep it up~

    • @agentgreenland
      @agentgreenland 7 лет назад

      HEEELP!
      at around 36:18, he says he gets the new tun0 network interface, because he had started the openVPN service, but I don't get that device when I type ifconfig...! :-\ Why is that...?
      I am running Debian 8.6 on Pi

  • @Crestoify
    @Crestoify 8 лет назад +1

    Welcome back Hak5, welcome back!

  • @WIKIKALI
    @WIKIKALI 5 лет назад +1

    Great tutorial
    A while ago I was looking for him

  • @ClevioGrenouille
    @ClevioGrenouille 4 года назад

    this is the best tutorial i have ever seen on the net.

  • @colorflydigital
    @colorflydigital Год назад

    The Best Explanation !!! I referred to many videos , but out of all tNice tutorials was the best I could find among all .... Also got to know many tNice tutorialngs

  • @recklessbeast
    @recklessbeast Год назад

    just 3 years away from 2026. You did great job regarding explanation.

  • @cyriljourdan1023
    @cyriljourdan1023 7 лет назад

    Finally a complete step by step tutorial, and it works, got it working on a Ubuntu 16.04 desktop and a nVidia Jetson TK1. Awesome ! Thanks !

    • @cyriljourdan1023
      @cyriljourdan1023 7 лет назад

      In fact it works well locally but not over the Internet. My client gives a TLS Error: TLS key negotiation failed to occur within 60 seconds.
      It looks like a firewall issue on port 1194. Anyone got this error ?

    • @pgwollan
      @pgwollan 7 лет назад

      Is it port forwarded?

    • @cyriljourdan1023
      @cyriljourdan1023 7 лет назад

      You mean on the router? I have a basic router where I can only do simple port mapping : I can set a local IP address, a protocol, local port and public port. I set my vpn server local IP to UDP and both ports to 1194, but it is not working. Is there something I missed ? Or my router is not suitable ? Thanks!

    • @pgwollan
      @pgwollan 7 лет назад

      Any router should have some form of port forwarding. What router do you have?

    • @cyriljourdan1023
      @cyriljourdan1023 7 лет назад

      I have the Vodafone EasyBox 804. Do you recommend any router ?

  • @baiqing
    @baiqing 8 лет назад

    Great job! You guys should do a video where you tunnel openvpn through Stunnel or any other methods that can bypass deep packet inspections. Getting Stunnel to work took me 10+ hours so I would love to see what other methods you guys can pull off!

  • @WoobiewookieBlogspot
    @WoobiewookieBlogspot 5 лет назад

    I know, I know, 2 years later...
    First, thanks for this - its very informative, and you'd be surprised how few VPN server setup walkthroughs there are out there. If you all are still paying attention to comments, it might be cool to give a refresher on why "allow ssh" on its own isn't very safe (just explain you're keeping your putty session active). Not sure if you guys have done a ssh keypair video but i'd love to see an updated/current one.

  • @MehdiHaghgoo
    @MehdiHaghgoo 4 года назад

    You guys are great! Keep up the good work!

  • @zainuddinbrahim4625
    @zainuddinbrahim4625 3 года назад

    i truly support ur programs guys because I am a unix guy.

  • @lebouski
    @lebouski 7 лет назад +1

    i love you guys. thanks for the awesome videos

  • @Nithintitta
    @Nithintitta 8 лет назад

    Thank you!! . gonna try this on my PI. I now know the steps I missed :D

  • @inhissteps-prasanna3532
    @inhissteps-prasanna3532 Год назад

    good work and thank you so much, Greetings from Egypt

  • @bryanburton3172
    @bryanburton3172 7 лет назад

    WOW, what a fantastic demo. I could follow every step. It was all crystal clear and matched my requirements precisely. Nice hats too.
    All working perfectly after realising I'd messed up by uncommenting the line "tls-auth ta.key 0 #" as directed by some shoddier how-to page. My bad should have come here first!!!. But Seriously, this was great. Thank You Thank You Thank you.

  • @farzadziaienezhad4673
    @farzadziaienezhad4673 3 года назад

    you're doing great, thanks!

  • @articcircleado
    @articcircleado 5 лет назад +1

    Literally the greatest

  • @tylermurphywilliams5866
    @tylermurphywilliams5866 8 лет назад

    been waiting for this

  • @JustinHyneswashplant26
    @JustinHyneswashplant26 7 лет назад

    Well said at the end.

  • @kc9aop
    @kc9aop 7 лет назад

    I "hacked" my way through this alone. I wish this video was available when I was working this out. Needless to say my solution is functioning the same but I ended up making things a bit more complicated. Great job on this video!
    I would like to see an ipv6 video.

  • @manuellenz3532
    @manuellenz3532 6 лет назад

    thanks a lot! you are a cool team!

  • @JoelWilhiteKD6W
    @JoelWilhiteKD6W 8 лет назад

    love the hats!

  • @bdonham
    @bdonham 8 лет назад

    Congratulations on the podcast Award.

  • @akhilyadav7722
    @akhilyadav7722 Год назад

    Right here with ya, bro

  • @leo-rq2ei
    @leo-rq2ei 6 лет назад

    Awesome tutorial 💯 thanks

  • @pierrotlunairehh
    @pierrotlunairehh 8 лет назад +13

    +1 for an 'ipv6 for dummies'!!!

  • @rubenb.molina6968
    @rubenb.molina6968 7 лет назад +2

    @Hak5 - I can't like this episode enough times!
    I will be playing around with OpenVPN server running on OpenWRT to manage a few remote networks. I also loved episodes #2017 and #2018; I'm drafting some ideas for my backpack "Network pocket" (housing hotspot gear, and extra storage, etc)...
    I'll publish a photo and tag yo guys. I need an extra nano =). #jokeNotjoke.
    Anyway - Love your show. I've been a fan for over nine years!

  • @libilybilly7074
    @libilybilly7074 5 лет назад

    Thanks a lot for your hak.

  • @chrisjchalifoux
    @chrisjchalifoux 7 лет назад +1

    ty i love ur videos

  • @androidgeek123
    @androidgeek123 8 лет назад +18

    Please do a Ipv6 episode!

  • @tzisorey
    @tzisorey 8 лет назад

    Yes, do an IPv6 episode! We need more people to be aware of, and fluent with, IPv6!

  • @jiaqint961
    @jiaqint961 7 лет назад

    this is fantastic!

  • @danielkun593
    @danielkun593 Год назад

    I feel you!

  • @prosperow
    @prosperow 7 лет назад

    this is great thanks

  • @jaredneaves7007
    @jaredneaves7007 5 лет назад

    Lifesavers thanks

  • @swivellogic
    @swivellogic 7 лет назад

    Yes, IPv6 and networking protocols please!

  • @tectubedk
    @tectubedk 8 лет назад +9

    for all the raspberry pi users check out pivpn it is the easiest way to install openvpn

  • @user-ie9yy2fd7j
    @user-ie9yy2fd7j 6 лет назад

    Hey!!! Just awesome

  • @adrianopinaffo
    @adrianopinaffo 3 года назад

    In 5 years I will come back to say that even though we have fireguard, this is still relevant

  • @luoarnamsk
    @luoarnamsk 8 лет назад

    I would love a IPv6 video!

  • @bullmarket7061
    @bullmarket7061 Год назад

    Please update this tutorial again. Make it based on new versions. Thanks. Awesome channel.

  • @zainuddinbrahim4625
    @zainuddinbrahim4625 3 года назад

    cool cool stuffs thanks guyss

  • @pingpong1138
    @pingpong1138 7 лет назад +3

    Man I love when things are badly documented

  • @hackstudent2762
    @hackstudent2762 7 лет назад

    thanks a lot + Please do a Ipv6 episode!

  • @YuryMartynov
    @YuryMartynov 8 лет назад

    thank you!!!

  • @hfrnd-hu2kz
    @hfrnd-hu2kz 7 лет назад

    Hey guys, been a real fan for a long time, quisck question... when you mentioned to be able to through this build into an arduino... any arduino specific in mind?

  • @techkenX
    @techkenX 8 лет назад

    would like to see a ipv6 episode as well.

  • @gerlisonlima6098
    @gerlisonlima6098 Год назад

    Bro it’s very intimidating! I’ve been slacking on it for a month now. The symbols are very confusing. You have to train your mind to

  • @touchpreyano7220
    @touchpreyano7220 6 лет назад

    Thank that help alot

  • @LCFTW93
    @LCFTW93 8 лет назад +19

    I would like an IPv6 episode
    Also why the Return on empty lines between commands?

    • @techkenX
      @techkenX 8 лет назад +6

      the empty lines is to keep things clean he always do that.

  • @sairarivera6993
    @sairarivera6993 Год назад

    and build tracks from there and leave the rest for a later session. I did both but did the first way initially and it took a day to get through

  • @luisgarnica1809
    @luisgarnica1809 8 лет назад

    IPv6 episode FTW!

  • @blazeafeef
    @blazeafeef Год назад

    I recomnd you two to buy the Producer Edition (And if you have got money, buy the Full Bundle)

  • @AllanFrench
    @AllanFrench 8 лет назад

    Can you guys do an episode on how o set up openVPN with a connection tethered from your phone ? You mentioned that's how you operate at home, and so do I. Would hugely appreciate it... And yeah we don't mind long episodes :-)

  • @RomanLeBg
    @RomanLeBg 4 года назад

    IIIIIIIIIIII LOOOOOOOOOOOOOOOOOOOOOOOOOOVEEEEEE YOUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU I spent straight 3 hour on the Arch wiki and now it work omg I was so so close 17:41 I put tun0 instead of the real one lmaoooo i'm so glad it work

  • @ubmate2997
    @ubmate2997 5 лет назад +3

    This was a great video. Any chance that this could be updated to reflect changes since 2016?

    • @dylanwestphal3582
      @dylanwestphal3582 4 года назад

      Not a lot of changes actually :) From what I know after a couple weeks extensive bed-time reading

  • @SupermotoZach
    @SupermotoZach 8 лет назад

    Shannon's mike seemed a lot louder than Darren's in this ep, just me? great ep though (y)

  • @tenminutetokyo2643
    @tenminutetokyo2643 6 лет назад

    Nice.

  • @cameronsteel6147
    @cameronsteel6147 8 лет назад

    Yes IPv6 episode please!

  • @surrealalucard
    @surrealalucard 7 лет назад

    @Darren! when going back and forth between directories, type cd -

  • @MinecraftAzsassin
    @MinecraftAzsassin 5 лет назад

    If you’re getting a KEY_CONFIG error stating the openssl.cnf is not correct or similar, use this while in the specified directory of the issue (where build-ca is located): ln -s openssl-1.0.0.cnf openssl.cnf

  • @adam32697
    @adam32697 7 лет назад

    ILOVE THIS GRIL !! SHE IS SUPER CUTE !!

  • @tectubedk
    @tectubedk 8 лет назад +78

    please make the ipv6 video

    • @WillBicks
      @WillBicks 8 лет назад +1

      Yes please.

    • @zizzu549
      @zizzu549 7 лет назад +2

      Yes please ipv6 video i remember it is a bunch of hex bytes to write one ipv6 address and i hate hex i have ten fingers :(

    • @kentosfreshmaker8850
      @kentosfreshmaker8850 7 лет назад

      I would like to see that as well. Its one of those things im not too keen on =/

    • @bearwolffish
      @bearwolffish 7 лет назад +2

      : ) The trick is to use the ridges in your fingers, along with the top of each. We have 8 fingers with 4 bits on each half byte, or hex from 0-F on one hand and 00-F0 on the other. This makes thinking binary and hex a little easier. Look up the Hexadecimal finger-counting scheme.

    • @TheSakeCat
      @TheSakeCat 6 лет назад

      anders ballegaard and I was feeling lost before you told me it gets more complicated.

  • @iamjohnhenry
    @iamjohnhenry 5 лет назад

    It appears that there have been a number of changes since 2016. Wondering if you might do an update for 2019?
    (I initially thought this was a 2019 tutorial because of the title.)

  •  8 лет назад +1

    you can make alarms & notifications with iptables when can you do a tut on this? :) it takes some googling but last time i checked it got advanced lol

  • @hasanordek
    @hasanordek 2 года назад

    Great video! But, this means for every user I have to create a user account on that Linux server?

  • @jonathanpascal7437
    @jonathanpascal7437 4 года назад

    don't you have to port forward in you router ? i'm confused this is different from other OpenVPN setups
    I did all of this and it's not what i'm looking for, BUT HEY I LEARNED SO MUCH ABOUT LINUX FROM THIS VIDEO !!! thanks guys.

  • @touhid.rahman
    @touhid.rahman 7 лет назад

    Dear Hak5 Team, it was a great tutorial! It helped me learning the complete process of setting up VPN very clearly. But I was wondering how to scale it up? For example, the openvpn server is running in one instance now. But how to use another instance behind a DNS (or Load balancer) so that the IP remain same but my service can handle more clients? Need this concept for academic purpose. Will you please make a tutorial on this topic, it will be really helpful. Thanks

  • @Lehi0001
    @Lehi0001 7 лет назад

    Edit :
    My appologies. When using a config file, omit the leading double dash "--" for the command. Simply put tun-ipv6 in it, then follow the rest.
    Original Post
    "For IPv6, you need to add the --tun-ipv6 to the profile/config file. You then replace IPv4 addresses with IPv6 addresses.
    Be warned. Most people are NOT on IPv6 yet, as most admins don't want to take the time to comprehend what the new formula is. Also, subnets become a thing of the past, due to the number of possible addresses being such that you could assign one to every grain of sand on Earth....
    Option explained :
    --tun-ipv6 Build a tun link capable of forwarding IPv6 traffic. Should be used in conjunction with --dev tun or --dev tunX. A warning will be displayed if no specific IPv6 TUN support for your OS has been compiled into OpenVPN."

  • @PayneJon77
    @PayneJon77 7 лет назад

    Hey just finding you two and love the video. I just recently tried to install openvpn on my Ubuntu 16.1 laptop and had a couple of questions. 1. is this usefull when you're travelling a lot, or rather is it still affective? 2. not sure why but I can't see openvpn in the manager, have I done something wrong?

  • @k00lk33f420
    @k00lk33f420 6 лет назад

    Can you guys do a video on NAT and port forwarding with IP tables??? Pleeeease??

  • @nebuchadnezzar7774
    @nebuchadnezzar7774 7 лет назад

    awesome vidorial* (new word) anyways I have a problem setting up the tap0 device in openvpn since I running this from a rPi I have it connected through ethernet. is it the same as the tun setup?

  • @dimitribiemond
    @dimitribiemond 6 лет назад +1

    2017 still relevant

  • @etzard
    @etzard 8 лет назад +14

    ip6 yes please

  • @CameronModding
    @CameronModding 6 лет назад

    You could buy a external drive with either windows or Linux and your HDD with the opposite so you can switch easily. that's what I do ;)

    • @CameronModding
      @CameronModding 6 лет назад

      And you can easily setup you laptop to boot from USB/external drive in the Bios

  • @Gazza2485
    @Gazza2485 8 лет назад

    Have you guys done a segment on proxy-chaining ?

  • @kristoffseisler2163
    @kristoffseisler2163 3 года назад +1

    will you ever post an updated version of this? half of the commands just wont work at all since easy-rsa has updated so much.
    and you are using sysV while 2020 pretty much uses systemd

  • @katanasteel
    @katanasteel 8 лет назад

    I'd add one thing... you probably should put your CA on another server than your openvpn server, just in case it gets compremised.
    else if the openvpn server gets cracked all they have is the CA's public key and not the private key to create their own valid vpn client confs

  • @MattCamp
    @MattCamp 6 лет назад

    any recommendations on tutorials that show how to enable Internet connection tunneling through this vpn configuration?