Paths / Network Security / Lesson 3

VPNs and Remote Access

Video + 10 min read

Accountant
Cafe Wi-Fi
VPN server
Finance server10.0.5.10
Stranger
They only see:k9$Lm2#xQ...
🔒Encrypted tunnel
VPNs and Remote Access
0:00 / 6:02 · VPNs and Remote Access
Chapters and transcript

VPNs and Remote Access An accountant is working from a cafe. She needs the finance server back at the office. But the cafe Wi-Fi is shared with strangers. Her laptop connects through a VPN, and a stranger nearby sees only scrambled data. In this lesson you will learn what a VPN protects, what it does not, and the dangerous remote access shortcuts that attackers look for.

What a VPN does A VPN, a virtual private network, creates an encrypted tunnel between your device and a VPN server, or between two networks. Nobody on the path can read or change what is inside. It gives two main benefits: privacy on untrusted networks like public Wi-Fi, and access to private company systems, without putting those systems on the internet.

What a VPN does When you connect to a VPN, four things happen. Your device proves its identity, usually with a password and MFA, or a certificate. An encrypted tunnel is set up. Your traffic travels through the tunnel. Then the VPN server sends it on, to the company network or the internet. IPsec, OpenVPN, WireGuard and SSL VPNs all aim for this.

What a VPN does not do VPNs are often sold as if they make you completely safe. They do not. A VPN does not stop phishing. It does not stop malware: infected downloads still arrive through the tunnel. It does not make you anonymous, because websites still track you with cookies and logins. And it does not fix weak passwords or unpatched software.

What a VPN does not do See it happen. The VPN is connected. The user opens a link from an email, and a login page appears. The address is not the real bank. The user types a password anyway. The VPN protects it on the way, and delivers it safely to the attacker. The tunnel cannot tell an honest site from a fake one.

What a VPN does not do There is also a question of trust. Without a VPN, your internet provider can see which sites you connect to. With a personal VPN, the VPN company can see this instead. You have moved your trust, not removed it. Be careful with free VPN apps. Running a VPN costs money, so ask how a free provider pays for it. And always follow your company policy and the law.

Types of VPN Businesses use two main types. A site-to-site VPN joins two whole networks, like a head office in Lahore and a branch in Karachi. The tunnel runs between the two gateways and is always on, so branch staff simply use the network. A remote access VPN connects one user device, like an accountant working from home. She runs a VPN client and logs in.

Types of VPN Remote access VPNs work in two ways. With a full tunnel, all traffic, even normal browsing, goes through the company, so its security tools can inspect it. With a split tunnel, only company traffic uses the tunnel, and the rest goes straight to the internet. Faster, but the company sees less. Remember, the VPN gateway faces the internet. Patch it quickly and require MFA.

Exposed RDP and SSH Sometimes an admin opens a server straight to the internet for quick access. RDP on port 3389 gives a full Windows desktop. SSH on port 22 gives a command line. Both are encrypted, so sniffing is not the problem. The problem is that anyone can try to log in. Automated bots scan the internet and guess passwords day and night. This is brute force.

Exposed RDP and SSH Check the login logs of any server with SSH open to the internet. You will usually see failed attempts from many IP addresses within hours. When bots get in, the result can be stolen data, or ransomware across the whole company. Exposed RDP has long been a common way in for ransomware groups. So the rule is simple: RDP should never be open directly to the internet.

Safer remote access A safer design. The admin first connects to the VPN with MFA. Then she uses a jump host, one hardened server with MFA and full logging. Only the jump host can reach the other servers. A bot on the internet cannot even see them. If servers are in the cloud, a managed access service from the provider is another option.

Safer remote access If SSH must face the internet, harden it. Use SSH keys, and turn off password login. Disable root login, so admins log in as themselves and use sudo. Allow only known IP addresses in the firewall. Watch the logs, and block addresses after many failures. For RDP inside the network, use Network Level Authentication, strong passwords, account lockout and MFA where possible.

Try it yourself On your own Linux server, you can see the settings SSH is really using. Run sudo sshd dash capital T, and search for password authentication and permit root login. Safer output says no for both. Before you turn off passwords, make sure your SSH key login already works, and keep your current session open while you test. Only check systems you own or manage.

Quick check Quick check. Your company VPN uses a split tunnel. While connected from home, you open a news website. Which way does that traffic go? Choose an answer.

Key takeaways Let us put it together. A VPN is an encrypted tunnel for privacy and private access. It does not stop phishing or malware. Site-to-site joins networks, remote access connects one user. Patch the VPN gateway quickly and require MFA. Never open RDP directly to the internet. And if SSH must face the internet, use keys and disable root login.

People work from home, from client sites and while travelling. Companies also have branch offices in different cities. All of them need to reach internal systems safely over the internet. This lesson explains VPNs and remote access, and the dangerous shortcuts that attackers look for.

What a VPN does

A VPN (virtual private network) creates an encrypted tunnel between your device and a VPN server, or between two networks. Traffic inside the tunnel cannot be read or changed by anyone on the path, such as other users on a cafe's Wi-Fi.

When you connect to a VPN:

  1. Your device proves its identity to the VPN server, usually with a username, password and MFA, or with a certificate.
  2. An encrypted tunnel is set up.
  3. Your traffic travels through the tunnel to the VPN server.
  4. The VPN server sends it on to its destination, either the company's internal network or the internet.

Common VPN technologies include IPsec, OpenVPN, WireGuard and SSL VPNs that run over HTTPS. You do not need to know how each one works inside. They all aim to give an authenticated, encrypted tunnel.

A VPN gives you two main benefits:

  • Privacy on untrusted networks. On public Wi-Fi, people nearby cannot read your traffic.
  • Access to private resources. A company VPN lets staff reach internal file servers and apps as if they were in the office, without putting those systems on the internet.

What a VPN does not do

VPNs are often sold as if they make you completely safe. They do not. A VPN does not:

  • Stop phishing. If you type your password into a fake page, the VPN delivers it safely to the attacker.
  • Stop malware. Infected downloads still arrive through the tunnel.
  • Make you anonymous. Websites can still track you with cookies and logins. The VPN provider itself can see where your traffic goes.
  • Fix weak passwords or unpatched software.

There is also a question of trust. Without a VPN, your internet provider can see which sites you connect to. With a personal VPN, the VPN company can see this instead. You have moved your trust, not removed it. Be careful with free VPN apps: running a VPN service costs money, so ask how a free provider pays for it.

Always follow your company's policy and your country's laws about VPN use.

Site-to-site and remote access VPNs

Businesses use two main types of VPN.

Type What it connects Example
Site-to-site Two whole networks, through their firewalls or routers Head office in Lahore joined to a branch office in Karachi
Remote access One user's device to the company network An accountant working from home reaches the finance server

With a site-to-site VPN, the tunnel runs between two gateways and is always on. Staff in the branch simply use the network. They do not start a VPN themselves.

With a remote access VPN, each user runs a VPN client on their laptop or phone and logs in. This is what most people mean by "the company VPN".

Remote access VPNs can work in two ways:

  • Full tunnel: all of the user's traffic, including normal web browsing, goes through the company. The company's security tools can inspect it.
  • Split tunnel: only traffic for company systems uses the tunnel. Other traffic goes straight to the internet. This is faster, but the company sees less.

Remember that the VPN gateway itself faces the internet. Attackers actively search for VPN devices with known vulnerabilities. A VPN gateway must be patched quickly when its vendor releases security updates, and it must require MFA.

The danger of exposed RDP and SSH

Sometimes an administrator wants quick access to a server from home and simply opens it to the internet:

  • RDP (Remote Desktop Protocol, port 3389) gives a full Windows desktop.
  • SSH (Secure Shell, port 22) gives a command line, usually on Linux.

Both are encrypted, so the problem is not sniffing. The problem is that anyone in the world can try to log in. Automated bots scan the whole internet for these ports and try common usernames and passwords day and night. This is called brute force or password guessing. When they get in, the result can be stolen data or ransomware across the whole company.

If you check the login logs of any server with SSH open to the internet, you will usually see failed attempts from many different IP addresses within hours. Exposed RDP has long been a common way for ransomware groups to get into businesses.

The rule is simple: RDP should never be open directly to the internet, and SSH should only be exposed with strong protection.

Safer remote access

Better options, from most to least preferred for most small companies:

  1. Put remote access behind a VPN with MFA. Staff connect to the VPN first, then use RDP or SSH to internal addresses. The servers are not visible from the internet at all.
  2. Use a jump host (also called a bastion host). This is one hardened server that admins log in to first, with MFA and full logging. Only the jump host can reach the other servers.
  3. Use a managed access service from a cloud provider, if the servers are in the cloud.

If SSH must face the internet, harden it:

  • Use SSH keys instead of passwords, and turn off password login.
  • Disable root login. Admins log in as themselves, then use sudo.
  • Allow only known IP addresses in the firewall, where possible.
  • Watch the logs for repeated failures, and use a tool that blocks addresses after many failed attempts.

For RDP inside the network, use Network Level Authentication, strong unique passwords, account lockout after repeated failures, and MFA where possible.

Try it yourself

If you have your own Linux server or virtual machine with SSH, you can check how it is set up. This command prints the settings SSH is actually using:

sudo sshd -T | grep -Ei 'passwordauthentication|permitrootlogin'

Safer output looks like this:

permitrootlogin no
passwordauthentication no

To change these, edit /etc/ssh/sshd_config, set PermitRootLogin no and PasswordAuthentication no, then restart SSH with sudo systemctl restart ssh (on some Linux systems the service is called sshd). Before you turn off passwords, make sure your SSH key login already works, or you will lock yourself out of a remote server. Keep your current session open while you test a new one.

Only check systems you own or manage. Trying to log in to other people's servers without permission is illegal.

Check your understanding

Answer every question correctly to complete this lesson. If you miss one, try the quiz again.

1. You use a VPN on public Wi-Fi and then open a phishing link and type your password into a fake login page. Does the VPN protect you?

2. A company connects its Lahore office network to its Karachi office network so staff can reach shared servers in both places. Which type of VPN fits?

3. Which change makes an internet-facing SSH server much harder to break into by password guessing?

Locked: answer every quiz question above correctly to complete this lesson.

Spotted a mistake or something unclear? Report a mistake