Connect to your Linux from Windows


You can connect to your Linux from any machine or even your mobile devices using SSH. Learn how to connect to your Linux from Windows easily below.

SSH stands for Secure Shell and it basically allows you to access your Linux computer or server remotely.

I’ll show you a simple way to use SSH (this is assuming you have a separate Windows computer to use to access your Linux and they are on the same WiFi or internet network)

You need to open your terminal (it’s Konsole in Debian)

First, get your local Linux address using this:

hostname -I

Now on your Windows PC: Download Putty

Once you’ve downloaded Putty, open it and you’ll see an interface like this:

Enter the local Linux IP address you got from your Linux earlier into the Host Name (or IP address) field and use Port 22 (this is the default port for SSH) and click Open.

Putty should then open a terminal window allowing you to log in to your Linux computer or server using your Linux username and password.

That’s it, you used SSH to connect to your Linux from Windows!

Connecting remotely from a different network

You already connected to your Linux on your local internet network from a different device, but what if you want to connect remotely from a separate internet network like when you’re on mobile data or in a cafe?

I don’t recommend opening your local home network to the world so I’m not going to explain how to do that in this post because it’s also a more complicated process, if you have a Linux web server or web hosting with SSH access and you want to connect to that, take a look at my post in Web Server Getting Started to see how to easily connect using SSH.

Make your SSH connection more secure with keys instead of a password

You can use keys instead of a password to connect to your Linux computer or server and it’s a lot more secure. It’s also more convenient since you no longer have to enter a password, it just needs a few minutes of your time to set up.

You need to do this on the Linux you intend to connect TO

First, generate your keys in the terminal with this:

ssh-keygen

It will show:

Generating public/private rsa key pair.
Enter file in which to save the key (/home/username/.ssh/id_rsa):

Press enter to save your keys to the default location.

It’ll then ask you for a password:

Enter passphrase (empty for no passphrase):

If you want the convenience of passwordless login, just press enter here. It’s obviously more secure to have a passphrase in case your computer itself is compromised for example.

Now it should show where your keys were saved, the key fingerprint and the randomart image.

The private key stays on your Linux computer or server, it’s the one you always keep private. The public key which is saved as a file called id_rsa.pub is used when you connect to your Linux and matches the private key to authenticate.

If you want to learn how to move the key with a USB stick and then use the key with Putty on Windows to login to your Linux securely without a password, see my other post: coming soon

Make your SSH login much easier

If you are using Linux and terminal to login to another Linux, for example from your home Linux computer to your Linux web server, you may be using something like: ssh [email protected]

If you also set up a custom SSH port instead of the default port (22), you will be typing: ssh -p 1234 [email protected]

If you want to make it this easy:

ssh server

Open your SSH config file:

sudo nano~/.ssh/config

Add the following:

Host server
    HostName 172.16.0.1
    User admin
    Port 1234
    IdentityFile ~/.ssh/id_rsa

Replace 172.16.0.1 with the IP address or domain name of the computer or server you want to connect to, the username “admin” with your username on the device you’re trying to connect to and the port “1234” with your custom port.

If you don’t have a custom port, you can enter 22 or leave out the line “Port 1234”

If you didn’t set up SSH keys and are still using a password to login you can also leave out the IdentityFile line.

Use CTRL + X to exit the nano editor and when prompted with “Save modified buffer?” type y and press enter.

Connect to your Linux from Windows: Conclusion

I hope this post helped you connect to your Linux from Windows successfully. In case you’re having any problems, I’ve included some links below to help you troubleshoot connection issues.

https://www.geeksforgeeks.org/how-to-troubleshoot-ssh-connection-issues/

https://www.ssh.com/academy/ssh/putty/windows