Setting up Wireguard on Linode

Also, seems to me you’re missing a command:

sudo apt install resolvconf

That’s the error you’ve been getting. :wink:

Okay @vasileios, I’m stuck again! I sure appreciate you! I have a Linode VPS. I used the script from OneMarcFifty to install Wireguard. I can log into the root of my VPS with ssh keys (I’m proud of myself for managing to do that successfully.) Now, I’m stuck. Wireguard is installed, but I can’t figure out how to run it. Just typing wireguard on a command line doesn’t work. Trying to list files in the root directory using ls gives me nothing. What have I missed?

Hey @PrettyGranny!
I personally haven’t spent much time on Wireguard, since it’s still under development - and therefore has a few issues that appear every now and then.

Wireguard, however, runs as a service, which - in most cases - is activated on the VPS as follows:

wg-quick up wg0

Provided that wg0 is the name of your initial configuration.

For the detailed steps - specific to Linode - you can check them in the link below:
https://www.linode.com/docs/guides/set-up-wireguard-vpn-on-ubuntu/

Since you have it installed on your VPS, you can safely jump to the Configure Wireguard Server section and take it from there.

Now why didn’t it occur to me to see whether Linode offered any help here? Feeling foolish.

However, I’m working through the detailed steps per the link you listed, and running into an issue. I’m logged into root@localhost:~#. The only thing a directory listing shows me now is my private and public keys, and wireguard-install.sh. Per the instructions, I’m supposed to create the file /etc/wireguard/wg0.conf, but I can’t seem to do it. The error message I get is “no such file or directory”.

A directory listing showing hidden files doesn’t show any such file or directory, but when I try to create them, it says Cannot create directory: File exists. Obviously, I’ve missed something. What now?

Hey @PrettyGranny!
When I go through an installation or a setup process, I always pull up additional instructions. Sometimes more than a single one, so that I have points of reference and comparisons. I can then go via any solution or create a hybrid from all of them. It all depends on the situations and that’s how I post most solutions here (most are hybrid ones, via extrapolation). But that can take trial and error, so don’t worry if you hit walls. :slight_smile:

Generally speaking, WireGuard, when installed via script generates a default wg0 configuration file. While you’re on your VPS as root, type in:

cd /etc/wireguard
ls -l

And see what files are available in there. If there is a wg0.conf then create a backup copy of it, for disaster-recovery purposes like:

cp wg0.conf wg0.backup

And then edit it via:

nano wg0.conf

You can navigate there via the arrow keys and do your edits. When done, CTRL+O (then Enter) will save your file, and CTRL+X will exit to bring you back to the terminal.

I’m so puzzled! This morning when I posted my last question, I couldn’t see ANY files, as I mentioned in my question. This evening when I went to try your instructions, a directory listing looks VERY different and everything is there! No idea what has changed except the time of day. I swear I haven’t done anything different. Have you seen this happen before?

Not only that, but my wg0.conf file is already complete and correct without my having to add the private key per the instructions I’m following. So that is done!

Now I’m stuck on the setting up the client side. I have generated public and private keys for Wireguard, but I apparently don’t have permission to access the /etc/wireguard directory to view wg0.conf on my local computer. Sigh! Now what?

Hey @PrettyGranny!
No need to worry! I tend to get lost myself when I’m tired or my mind is elsewhere. This is why I tend to go fully technical when my mind is clear and I’m rested. :slight_smile:
Before, you were at your home folder, where you downloaded the WireGuard installation script. That’s why you couldn’t see the configuration files.

Per your local system, here’s the difference:
When you perform these actions on your VPS, you are logged in as - or elevated to - root. That’s why you don’t need sudo privileges.

When you’re on your local system, you are logged in as a normal user, hence the permission denied message. What you’ll need to do is add sudo before any command or simply type in:

sudo su

And then execute the commands without using sudo. However, when you’re done with the terminal commands, remember to type in:

exit

To leave root mode, so that you don’t accidentally cause harm to your OS. :slight_smile:

My VPN project got tabled for a bit; my schedule has been pretty full of late. Now that I’m back to it, I was able to open my client side wg0.conf successfully, and so far as I can tell, it looks right. Now the issue is that I can’t log in to my VPN using ssh: Permission denied. How do I overcome this one? I know I’m typing in the password correctly. I can successfully ping the VPN, but I don’t think the wireguard stuff is connecting.

Hey @PrettyGranny!
When you setup your VPS, did you change the SSH settings to not allow Root Login or Password Login? If you have, it won’t let you in.
The main reason is that in all our LMS courses, we introduce the use of SSH keys to get someone logged into a VPS. To that extend, I’m having another guess:

If you set up an SSH key, did you input a passphrase for your key? If yes, then the password you’re entering will be for that SSH key and not for your VPS. :slight_smile:

so you are saying that when I use ssh root@[ip address], rather than the password I should use the passphrase? I tried that with identical results. :frowning: I’m so lost!

Hey @PrettyGranny!
When you try to login as root, it won’t allow you in, since “RootLogin” is locked from within the SSH settings. You’ll need to login as your non-root user that you created during your VPS setup. :slight_smile:

However, if you still have troubles, you can still login as root, then you can go to your Linode account, select your server and then select the LISH button on the top right of your screen. It will bring up a new window with two tabs. One is the WebLISH and the other is the GLISH. I’d recommend the latter, since the WebLISH can be distracting with the kernel messages it pops every now and then.

Please let me know how it goes.