Note: This post is 7 years old. Some information may no longer be correct or even relevant. Please, keep this in mind while reading.
HTTPS on 100% of websites in the internet? This just has gotten a lot easier! Let’s Encrypt is a free, automated, and open certificate authority (CA), run for the public’s benefit. Let’s Encrypt is a service provided by the Internet Security Research Group (ISRG), a Section 501(c)(3) Non-Profit entity dedicated to reduce financial, technological, and education barriers to secure communication over the Internet.
Automated API? This sounds too complicated! It is actually not. There are a number of API libraries and clients available that do the work for you. One of them is Certbot. It is a regular command-line program written in Python and the source code is available on Github.
After downloading the certbot-auto script (see their documentation), fetching certificates consists of just one command line (in this example certs for 3 domains are fetched in one command with the -d switch):
With the -w flag you tell the script where to put temporary static files (a sub-folder .well-known will be created) that, during the API control flow, serve as proof to the CA’s server that you have control over the domain. This is identical to Google’s method of verifying a domain for Google Analytics or Google Webmaster Tools by hosting a static text file.
Eventually, the (already chained, which is nice!) certificate and private key are copied into /etc/letsencrypt/live/example.com/ :
Then it is only a matter of pointing your web server (Nginx, Apache, etc.) to these two files, and that’s trivial.
Let’s Encrypt certificates are valid for 90 days. The automatic renewal of ALL certificates that you have loaded to your machine is as easy as …
… which they suggest should be put into a Cron job, run twice daily. It will renew the certificates just in time. No longer do you have to set a reminder in your calendar to renew a certificate, and then copy-paste it manually!
A bit of a downside is that Let’s Encrypt unfortunately doesn’t support wildcard domain certificates. For these, you still have to pay money to some other CA’s who support them. But in above shown code example, you would generate only 1 certificate for the domains example.com and its two subdomains www.example.com and blah.example.com. The two subdomains are listed in the Subject Alternative Name field of the certificate, which is as close to wildcard subdomains as it gets. But except for SAAS providers and other specialized businesses, not having wildcard certificates should not be too big of an issue, especially when one can automate the certificate setup.
On the upside, they even made sure that their certificates work down to Windows XP!
Today, I set up 3 sites with Let’s Encrypt (one of them had several subdomains), and it was a matter of a few minutes. It literally took me longer to configure proper redirects in Nginx (no fault of Nginx, I just keep forgetting how it’s done properly) than to fetch all the certificates. And it even gave me time to write this blog post!
Honestly, I never agreed with the fact that for commercial certificate authorities, one has to pay 1000, 100 or even 30 bucks per certificate per year. Where’s the work invested into such a certificate that is worth so much? The generation of a certificate is automated, and is done in a fraction of a second on the CPU. Anyway, that now seems to be a thing of the past.
A big Thumbs-up and Thanks go to the Let’s Encrypt CA, the ISRG, and to Non-Profit enterprises in general! I believe that Non-Profits are the Magic Way of the Future!
Note: This post is 8 years old. Some information may no longer be correct or even relevant. Please, keep this in mind while reading.
What to do when Teamviewer suddenly doesn’t connect or you can’t or don’t want to use it for other reasons? What if a friend needs urgent assistance and you need to see his screen to help out? Standard Open Source tools to the rescue! If you know how to use SSH from the command line and have access to an user account on a remote server running SSHD, then this article will save you!
Teamviewer-like products are so popular because they solve a real problem: To connect from one household computer to another is not straightforward because we all use regular modems/routers to connect to the internet. They are usually not set up for Port Forwarding. In laymans terms this means: You can initiate a connection to the internet, but the internet never can initiate a connection to you. This quandary has only one solution: an intermediary is needed. Teamviewer-like products all offer such intermediary servers. Data is never directly sent from one computer to the other. Data is passed through a server (which allows for all kinds of spying by the way, if the encryption is not good enough!)
There are tons of (unfortunately for me) half-working instructions in the web about how the commands must look like. I took me several hours to wrap my mind around the problem. For this article, I’ve decided to make an image gallery so that you can see easier what is going on behind the scenes. Running just 4 commands will do the trick!
The following list and image shows the starting point of our situation:
We are sitting in front of the computer called “sittinghere”.
We want to see the screen of the computer called “overthere”.
There is a server called “hopper” which runs an ssh daemon (sshd) listening on the standard port 22. Our data will ‘hop’ though there, hence the name “hopper”.
We instruct our friend, sitting in front of the computer “overthere”, to start any kind of VNC server. There are many products for Windows, Mac OS, and Linux available. I’m using Linux and decided for x11vnc because it allows access to the screen of the currently logged in user instead of starting a new user session. The command is:
After this command, our situation has changed. See the following image. The VNC server has started listening on port 5900 (see lower right corner):
Now we have to instruct our friend, sitting on “overthere”, to run a ssh command to connect to “hopper”. You can make a little batch script for this to make it more convenient, but this is not the focus of this article. The command is:
ssh -R 7001:localhost:5900 email@example.com
With this command, sshd on “hopper” is instructed to create a socket on port 7001. And when someone connects to this port, it will be as if the same connection had been made on “overthere” port 5900. In the code above, “localhost” refers to the computer “overthere” because the command is executed on this computer.
Let’s see how our situation now looks like:
Now that “overthere” has done its connection to “hopper”, it is time for “sittinghere” to connect to “hopper” too. Here is the command:
ssh -L 7002:localhost:7001 firstname.lastname@example.org
This means: A socket on port 7002 will be created on localhost (“sittinghere”). If someone connects to this port, it will be as if the same connection had been made on port 7001 on “hopper”. Here’s the new situation:
Now, remember that a connection to port 7001 on “hopper” will have the same effect as if the same connection had been made on “overthere”. This means we will have a kind of ripple-through effect: As soon as we connect to port 7002 on “sittinghere”, the connection will ripple through until it connects to port 5900 of “overthere”. And this endpoint is our VNC server.
Now let’s connect with a VNC client from “sittinghere” to “overthere”. You will find lots of good VNC clients in the internet. Just connect to localhost:7002 which is equivalent to 127.0.0.1:7002.
This will start our connection cascade, and the final situation looks like this:
Congratulations, we’re now all connected through! If you have set a password (we’ve set it to “PASSWORD” in the above example), you now will see the remote screen. Note that we didn’t even have to execute a command on “hopper”, nor even reconfigure any firewall! My experience is that the quality and speed of the transmitted remote image is very good.
The SSH connections will stay alive until you terminate them. So, just type “exit” in the ssh terminals opened at “sittinghere” and “overthere” that we have been opened previously (to “hopper”).
Note: This post is 9 years old. Some information may no longer be correct or even relevant. Please, keep this in mind while reading.
I am using the Wireless (WLAN) mainly to connect my mobile phone to the internet, for faster downloads and to test mobile apps. First, I only used Apple devices (such as iPad, iPod, iPhone, etc.), and those could connect without problems to a so-called Ad-Hoc network. However, many mobile devices, such as Android, unfortunately will NOT connect to an Ad-Hoc network, for reasons which are very well explained on this How-To Geek posting (it taught me about many things I didn’t know!).Since I’ve recently given up on Apple products and only use Android phones, I needed a definite answer to this problem. And I found it today.
As you may know, there are basically 2 modes to operate a wireless network: “Ad-Hoc” and “Infrastructure” (the latter one also called “Access Point” or shorter “AP”) mode. Cheaper Wireless cards only support the Ad-Hoc mode, but do NOT support the AP mode.
It is supported beginning with Kernel version 3.2. I mounted it, and was planning to use the Network Manager of Debian Wheezy / Gnome 3 to quickly set up an AP Hotspot. Easier said than done! Because even though there is an option to set “Infrastructure” mode, my Android phone still would not connect. It would simply write “Ad-Hoc Connecting” and stop there, even though I had set the Infrastructure mode.
I had to wade through a LOT of web postings, all suggesting not-really-working ‘solutions’ until I found a synthesis of all the collected information that worked for me.
It turns out that you need a dedicated user-space program for ‘driving’ the AP hardware contained in your network chip, and this is hostapd . It seems, you can’t do without.
I found this blog which offered a bash script to automate the job, but it only worked for Ubuntu, and not for Debian due to different configuration files. I also found this little Qt program that made the wireless connection work for my phone, but disconnected my laptop from all networks.(It could have been my fault due to misunderstandings though…)
This blog did a good job in explaining what hostapd is and gives basic installation and configuration instructions. You should read the post in any event. However, the suggested final solution did not work for me. Yes, the phone would see the generated wireless network, would connect, but immediately disconnect. I have not found the reason for the failure, but it probably lies hidden in the complexity of the set-up which painstakingly involves
a locally run DHCP and DNS server,
configuration of same,
and manual calls to iptables (masquerading, forwarding, etc.) to route between eth0 and wlan0 devices
The author of this blog wrote a second post to avoid the locally run DHCP server in favor of re-using the DHCP server of the network (e.g. the modem) by using dnsmasq , which is yet another locally run server, only a bit simpler, but has to be configured also. I tried it to no avail. Same problem: phone would disconnect immediately. Frustrated, I moved on.
Then I found ths blog which brought a new idea: the concept of bridging between network interfaces instead of using iptables, which, and this is the good news, is supported ‘natively’ by hostapd and the Linux networking system configured by /etc/network/interfaces . However, this solution still did not work for me. After modifying /etc/network/interfaces accordingly, I managed to mess my internet connection up. It turned out that setting up a bridge between Ethernet and Wireless is not that trivial! Even the highly official Debian Wiki BridgeNetworkConnections would not give working results for my case. So, I startedcrossreferencingbetween other solutions and finally came up with the following sequence of commands that work for me on my pretty standard Debian Wheezy laptop with one ethernet adapter (eth0) and the above mentioned Intel network adapter (wlan1). You only need to install 2 packages (bridge-utils and hostapd). With my method, there is no need for a locally installed DHCP or DNS server, and no need to modify the /etc/network/interfaces file. There is no requirement to permanently make changes to your network configuration. In an emergency (if you are stuck somehow), a reboot will reset your network configuration to the defaults. Devices connected to your newly created wireless network will be served by the DHCP and DNS server specified in your router/modem. Your mobile phone will be a regular and equal member of your LAN.
You can turn the following listed commands easily into a Bash script with ‘start’ and ‘stop’ arguments. But I’ll leave that up to you. It’s easy enough once you copy/past the following commands into a terminal window. So, without further ado, as superuser…
… install bridge-utils. These are helper programs.
apt-get install bridge-utils
Next, remove the attached IP address from the Ethernet card eth0. Bridging will not work when an IP address is set.
ip addr flush dev eth0
Next, turn on IPv4 networking for your wireless card. This is necessary, otherwhise one of the next steps will give the error “can’t add wlan1 to bridge br0: Operation not supported”.
iw dev wlan1 set 4addr on
Next, create the actual bridge br0 with the helper program brctl:
brctl addbr br0
Next, bridge between Ethernet and wireless. The order of the last two arguments is not important:
brctl addif br0 eth0 wlan1
Next, bring the newly created bridge up, as a virtual device:
ip link set dev br0 up
At this point, you will have lost your connection to your LAN/WAN. You have to set an IP address, net mask, router, etc. for the bridge. We do this via DHCP:
Now you should be able to access the internet again. Test it! If it doesn’t work, just reboot your computer. We have not made permanent changes to your system (another advantage of this method!)
So far so good. Now we have to create our actual wireless network in AP mode and use our Android phone to test it. Install hostapd:
apt-get install hostapd
Create a configuration file somewhere on your drive. I chose the location /etc/hostapd/my-wlan.conf . Make sure you have the right driver set for your card (see above mentioned blog for more info. n180211 should work in most cases):
#sets the mode of wifi, depends upon the devices you will be using. It can be a,b,g,n. Setting to g ensures backward compatiblity.
#macaddr_acl sets options for mac address filtering. 0 means "accept unless in deny list"
#setting ignore_broadcast_ssid to 1 will disable the broadcasting of ssid
#Sets authentication algorithm
#1 - only open system authentication
#2 - both open system authentication and shared key authentication
######Sets WPA and WPA2 authentication#####
#wpa option sets which wpa implementation to use
#1 - wpa only
#2 - wpa2 only
#3 - both
#sets wpa passphrase required by the clients to authenticate themselves on the network
#sets wpa key management
#sets encryption used by WPA
#sets encryption used by WPA2
Now, simply start hostapd with this configuration file as the only argument:
You will see debug messages helping you to see what is going on behind the scenes. Now use your Android phone, enable WIFI, wait for the network “networkname” to appear, connect to it, enter the password “12345678”, open up a browser and see if it works. Make sure that Wireless is turned on in your Network Manager:
Otherwise you will get the following messages:
rfkill: WLAN soft blocked
Could not set interface mon.wlan1 flags: Operation not possible due to RF-kill
nl80211: Failed to set interface wlan1 into AP mode
To turn off wireless (you really don’t want to be grilled by microwaves 24 hours a day!), you cannot just turn Wireless off in your Network Manager since it seems to ‘damage’ the bridge (I have yet to confirm this a second time), and you won’t be able to access your network/internet. You have to ‘deconstruct’ the bridge in the following way:
ifconfig br0 down
brctl delbr br0
ifconfig eth0 down
ifconfig eth0 up
Only after that, you can turn of Wireless in your Network Manager. Again, if you are stuck, just reboot.
I hope this helps somebody, it worked for me, if not, write me a comment.