I've been trying to use ssh to connect to my machine back home.
But everytime I tried to connect it when I'm not locally it always resulted in a "connection timeout"
I can't ping it and I tried to use netcat as well with specific port. No responses.
Maybe I've missed something.
This is the condition of my linux machine at home:
- I am using private/public key for the authentication, and I have copied the public key to my linux machine already
- My linux environment at home is Ubuntu 22.0.4.1 LTS
- I have disabled password authentication
- If I am on a local network it always work, just not remotely
- My ISP does not assign a static IP but everytime I try to connect it, I always check the current IP that the ISP gave to my network.
- I have set a different port [x] to my linux machine
What I have done to try to fix it:
Set my sshd_config to keep alive on my linux machine
Create a port forwarding rule on my router from specific port [y] to port [x] that is set on my linux machine, and also for the ip address I have set it to the ip address that my linux machine corresponds to locally. I set UDP & TCP to allow
Since I am using ubuntu, I used ufw to set the rule to allow port [x] for my firewall
Check if my ssh is running, and everytime I have checked it states that its "active"
This is the ssh command I use ssh -i [.../mykey] [username]@[wan ip] -p [y]
I tried using a VPN to tunnel to my home and act like I'm locally. It works but its not compatible with all of my devices. So, I'm looking for a way to connect using ssh without VPN.
Note:
- It just doesn't work when using my Public IP & currently the way I'm testing using Public IP is by connecting my laptop to my mobile phone's network.
- My laptop's public key is already registered in the host's authorized_keys
- I retrieved my public ip using
curl ifconfig.me
- I've asked this question initially from stackoverflow but after some time I think ubuntu's stack exchange is more appropriate so I moved it here.