How to remote ssh into my PC?

So my PC has this issue that it freezes, then shortly after the display goes out and I have to hard reboot it. Luckily this is very seldom, but still annoying.

Somewhere in the past I have read, that one might still be able to remote connect to it (via ssh) and then check it or issue commands like a graceful reboot.

So how would I do that? (please explain for a noob). Ideally I want to use my phone for the connection, there are some ssh apps on f-droid.

Thanks!

Yes you can but you’ll have to open port 22 (the usual SSH port) in your router and forward it to your pc or use your personal VPN for a more secure connection. I use the connectbot app on my phone which is open source and available in f-droid. In the settings add a new host see > https://www.techwalla.com/articles/how-to-use-connectbot

I recommend using a VPN to connect to your home network for a secure connection.

2 Likes

I’m trying from my local WLAN, however I’m getting:

failed to connect to /192.168.1.02 (port 22) from /:: (port 51042)
led: ECONNREFUSED (Connection refused)
connect failed: ECONNREFUSED (Connection refused)

Is there anything I need to do local on my machine?

sshd needs to be running

You need to enable the service as mentioned, for example enteringsudo systemctl enable sshd.service. You should then be able to log in via ssh on port 22 (unless you manually change). There are many ssh options that can be configured in the config file, if you need any further info I’m happy to try and help.

Just to clarify as well, you shouldn’t need to port forward port 22 unless trying to access from outside your local network. As Chomsky states, if this is something you wanted to do, a VPN may be a better option. Personally, I access my home network from outside by having a VPN server on my home network that, once connected to, I can ssh from to any other device that I have ssh activated on. I therefore only need to port forward the port I use for my VPN to my VPN server.

1 Like

Ok, cool with sshd.service running it works!
My PC isn’t running when I’m not at home, so I really don’t need that VPN service.

So what are some good commands to check the status of my PC and possible unfreeze (assuming I can still ssh into it)?

to see what is running on my devices, I tend to use htop. This will show you running processes, and you can order by e.g. processor use. If your computer is still responding to ssh commands, you can use kill to stop processes you need to, or you could for example reboot if necessary.

Don’t put 0 in the IP unless it is actually required.

  • 192.168.1.2 - correct
  • 192.168.1.02 - incorrect

If you can ssh into the system you use htop to show what’s going on.

Select the offender and F9 then press Enter to send a SIGTERM.

Kind of off topic but since you mentioned a hard reboot:

1 Like

Don’t do this. Never! You will be bombarded with login attempts. You should open a completely unrelated port on the router and then forward it to port 22 in your computer. Alternatively you can change the sshd port in /etc/ssh/sshd_config and then open it in your router.

I use a VPN to connect to my home network and when I didn’t I had fail2ban installed.

Yes, I used fail2ban also, but it’s much more efficient to have a different port forwarded (or a VPN). It’s so efficient that I even stopped using fail2ban due to the absence of login trials.

1 Like

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.