Linux.com

Feature: Security

Secure your Wi-Fi traffic using FOSS utilities

By Donald W. McArthur on September 12, 2006 (8:00:00 AM)

Share    Print    Comments   

A recent Slashdot item on Wi-Fi security was a timely reminder of the weaknesses of default Wi-Fi encryption protocols, and the dangers of using unencrypted, public Wi-Fi connections. Fortunately, you can use FOSS utilities to securely tunnel your Wi-Fi connection sessions and protect your Web and email traffic.

To facilitate encrypting your Wi-Fi traffic, first set up dynamic DNS service so you can locate your server when you're away from home. You then port-forward SSH connections through your router to an SSH server, configuring the server to accept only key-authenticated connections. You can then tunnel your email and Web traffic from a remote client through an encrypted SSH tunnel into your home network, and then on to the Internet.

To start, be sure you have an SSH client on your laptop and a Linux server on your home network that is running the sshd daemon, and be sure that the server's iptables-based software firewall is configured to allow SSH connections.

On my own network I have a Linksys WRT54G Wireless-G Router that serves as my home's gateway router, an SSH daemon running on a CentOS 4 server on my home network, and Ubuntu Dapper Drake running on my laptop, where I use the Firefox browser and the Thunderbird email client.

Finding your SSH server when you're on the road

Most ISPs provide dynamic IP addresses for residential customers, which can complicate your connection efforts when you are on the road. Dynamic DNS lets you specify a domain name that always points to your residential server. To start using dynamic DNS, register an Internet domain with a low-cost registrar. I use GoDaddy, and I have been pleased with how easy it is to make changes in the DNS server properties for my domains. For dynamic DNS service, I've been using ZoneEdit, which has provided reliable service and support. ZoneEdit does not charge you for the first five domains for which they provide DNS service, as long as traffic levels are reasonable.

For complete details on getting started with dynamic DNS, read this Linux.com article.

Configuring the SSH client and server

Prior to exposing your SSH server to the Internet, and the inevitable automated scans and username/password brute force attacks, you will want to make some configuration changes to restrict SSH connections to public key/private key exchanges, and to eliminate the username/password logins that are subject to random guessing efforts. This is not only easy to configure, but simplifies SSH access in general.

Begin by generating a public/private key pair for your laptop to use for connecting to your SSH server. Log on to your laptop and enter the following command at the user prompt:

ssh-keygen -t dsa

This will generate a public/private key pair that will be used to connect to the SSH server. The keys are stored in the directory /home/user/.ssh.

You now have to append the user's public key to a specified file on the SSH server. Create an account on the SSH server for the user, and in the home directory for that account, create the following directory and file:

mkdir .ssh
touch .ssh/authorized_keys

The easiest way to append the user's public key to the file is to use SSH from the laptop:

cat ~/.ssh/id_dsa.pub | ssh user@sshserver_ipaddress "cat >> .ssh/authorized_keys"

Change the permissions on the file on the SSH server so that it is readable only by the user:

chmod 600 .ssh/authorized_keys

Now you should make the changes to the SSH server's configuration file to tell it that only public/private key connections are allowed. On CentOS 4, the configuration file is /etc/ssh/sshd_config. Before you start, make a backup copy of this file, and make sure you have console access to the server in case you err and lock yourself out. As root, scroll through the file and make changes and additions so that the following lines are the only ones uncommented, and that they read as indicated:

#Port 22
Protocol 2

# HostKeys for protocol version 2
HostKey /etc/ssh/ssh_host_dsa_key

# Logging
SyslogFacility AUTHPRIV

# Authentication
PermitRootLogin no
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys

# To disable tunneled clear text passwords, change to no here!
PasswordAuthentication no

ChallengeResponseAuthentication no

UsePAM no

AllowTcpForwarding yes

GatewayPorts yes

TCPKeepAlive yes

Compression yes

# override default of no subsystems
Subsystem sftp /usr/libexec/openssh/sftp-server

Again as root, restart your SSH server:

service sshd restart

Then, from your laptop, test the connection:

ssh user@sshserver_ipaddress

The connection should be automatic, and you should not be prompted for a password. You can also test that no connections are allowed for users without public keys on the server:

ssh smith@sshserver_ipaddress

This should not generate a request for a username/password, and should instead result in:

Permission denied (publickey).

You will want to repeat these steps for each client that you plan to allow to connect to your SSH server.

Port forwarding your SSH traffic to your server

Port forwarding When you start your remote SSH session from the command line with ssh yourdomain.com , the DNS lookup will be directed to dynamic DNS provider's DNS servers, which will respond with your current IP address. When the SSH connection request arrives at your home network's gateway router, it must be forwarded to the correct computer on your internal network.

You must configure port forwarding on your gateway router, generally by accessing its configuration application with a browser from inside your home network. On a Linksys router like the one I use, select the menu item Applications & Gaming, where you will find the configuration settings for port forwarding. By default, SSH traffic uses port 22. Any inbound traffic that arrives on port 22 must be forwarded to the internal network IP address of the computer running the SSH daemon. Responses sent back to the client will be directed by the router to the appropriate requesting client. Here is an image of the Linksys WRT54G settings I use:

Now you're ready to set up an encrypted tunnel. On the laptop, launch the encrypted connection from the command line with a command like:

ssh -D 2000 yourdomainname.com

The -D 2000 switch sets up a persistent connection listening on port 2000 on the laptop. After you finish testing, you can put this command in a bash script and launch it from your laptop's menu bar.

Configure applications to forward traffic through the tunnel

SOCKS Once you have a good connection, you have to tell your applications to use it. In both Firefox and Thunderbird, choose the menu items Edit -> Preferences -> Connection Settings. Select the radio button for manual proxy configuration, and at the section for SOCKS Host, enter localhost and then Port: 2000. Above is an image of my settings:

That's all it takes. All future Thunderbird and Firefox traffic on the laptop will be forwarded to the listening SSH client on port 2000, sent down an encrypted tunnel to the SSH server on your home network, and then forwarded out to the Internet through your home router. As an additional benefit, as far as your ISP is concerned, your laptop will always be at home, and will therefore have access to your ISP's SMTP server for outbound email. And you'll no longer have to worry about crackers sniffing your Wi-Fi traffic, no matter where you are.

Share    Print    Comments   

Comments

on Secure your Wi-Fi traffic using FOSS utilities

Note: Comments are owned by the poster. We are not responsible for their content.

needs more bandwidth

Posted by: Anonymous Coward on September 12, 2006 04:21 PM
nice but not really feasible with limited upload bandwidth

#

Re:needs more bandwidth

Posted by: Anonymous Coward on September 13, 2006 12:19 AM
I run this server from a 2MB downstream/.5MB upstream cable modem ISP and it works fine. Dial-up speeds would present an issue.

Don McArthur

#

Incorrect title

Posted by: Anonymous Coward on September 12, 2006 05:02 PM
The article may be useful but is about securing a connection over the internet, not over wifi.

#

Re:Incorrect title

Posted by: Anonymous Coward on September 12, 2006 09:30 PM
I agree. These are general things that anybody should do when sensitive communications are done over an untrusted network.

My method uses IPSec. At work, we decided that, since wireless connectivity is inherently insecure, we needed a way to encrypt it at each of our sites. We use Cisco routers, which do support IPSec, so we just made each site's access router into an IPSec gateway and stuck all the wireless access points on a separate VLAN w/ its own IP subnet. The router subinterface that services this VLAN has an access control list on it that says "only IPSec traffic and dhcp requests may talk to me." So, you can get an IP address all day. But you can't go anywhere unless your traffic is IPSec-tunneled.<nobr> <wbr></nobr>:-) Yes, you can still sniff all day, true. But remember that all our folks using wireless are also using IPSec, so they're not accepting any traffic other than their own IPSec tunnels (we force that at the VPN gateways), so attackers are stymied.

Granted, most home users don't have Cisco 2821's at their homes, and Cisco gear is "kinda" pricey, but this general solution does work very well for us for securing wireless. But Cisco IOS is not Free Software, sadly. I remember a couple of years ago reading an article on how to do this with an OpenBSD router; what I describe here with Cisco routers should apply exactly to OpenBSD routers as well. The key here is IPSec and VLAN separation.

#

Re:Incorrect title

Posted by: Anonymous Coward on September 13, 2006 12:22 AM
I use this system daily to tunnel my traffic over my wifi connection at home, to my home server, and then on the the Internet. Also when I am at a remote location connected to unencrypted wifi. So yes, this tunnels traffic over the internet, but was written from the point of view of protecting yourself while using wifi.

Don McArthur

#

Re:Incorrect title

Posted by: Anonymous Coward on September 13, 2006 11:15 PM
You guys are missing what this is really doing... it IS encrypting while at home on your wifi, because you ALWAYS route to your ssh server even when on the home network.

#

Couple of things

Posted by: Anonymous Coward on September 13, 2006 12:09 AM
You can copy the key to the server using ssh-copy-id. The nice part about that is it fixes the permissions up automatically.

Secondly, there are many programs available to protect your ssh server from brute force attacks. Personally I use DenyHosts, which is a highly configurable python script that montiors your ssh log file and bans users who try and connect to many times with wrong usernames or passwords.

More information about DenyHosts can be found at their website: <a href="http://denyhosts.sourceforge.net/" title="sourceforge.net">http://denyhosts.sourceforge.net/</a sourceforge.net>

#

Re:Couple of things

Posted by: Anonymous Coward on September 13, 2006 12:32 AM
Good idea. What I have always done is just use secure webmail and of course encryted sites but this is just one more step you can take. If your on cable you need to trust your neigboors if you are using regular pop or imap.

#

Re:Couple of things

Posted by: Anonymous Coward on September 13, 2006 12:58 AM
You may find that your cable service functions as a switch, and not a hub. The only traffic that arrives at my cable modem is traffic directed to me, not my neighbors.

#

Re:Another way to do it

Posted by: Anonymous Coward on September 13, 2006 05:11 AM
Interesting, I hadn't seen that before, thanks. You can of course export a GUI session with ssh by adding the '-X' argument, but the delays can be painful. The compression nx is using must be impressive.

Don McArthur

#

Re:Another way to do it

Posted by: Anonymous Coward on September 13, 2006 06:18 AM
I'll cast another vote for the NX Server solution. It really is impressive. I have FreeNX Server running on my Ubuntu Desktop at the house and it works great!

#

What

Posted by: Anonymous Coward on September 18, 2006 04:01 AM
This is so complex that normal people won't even know what it does, let alone be able to use it!

#

Re:What

Posted by: Anonymous Coward on January 15, 2007 10:09 PM
Unfortunately security IS painful. You have to be aware of the risks and the strategies to mitigate risks.

On the other hand, ignorance is bliss.

So you DO have a choice.

G. Fernandes.

#

Re: What

Posted by: Anonymous [ip: 62.58.36.57] on January 04, 2008 10:58 AM
Disagreed.

I'd recommend that the author split this article up in at least 3 advices (how-to ssh behind an ADSL/cable router, how-to SOCKS proxy using ssh -D, how-to PK-auth using ssh). Not all of this info is pertinent.

The essence boils down to: afraid someone will eavesdrop when you use insecure internet? Setup ssh so you can use your home box as a secure proxy (provided you trust your ISP :)).

Most folks would recognize the machinery around it, if not, yes it is a lot to swallow at once.

#

Another way to do it

Posted by: Administrator on September 13, 2006 03:37 AM
I'm using NX to run remote desktop on my home server. I can do it from my office, or from the home laptop.
NX uses ssh to encrypt all traffic and advanced compression techniques to make it comfortable even across the slow connections.

#

This story has been archived. Comments can no longer be posted.



 
Tableless layout Validate XHTML 1.0 Strict Validate CSS Powered by Xaraya