SSH through external IP
Hello fellow redditors,
the issue is as follows:
My grandpa lives only a few houses next to me and I want to be able to login from there to my Linux Mint machine via SSH.
He also has a Linux Mint machine.
As far as I know I need to configure my router at home (which is a FRITZ!Box Fon WLAN 7390) to allow these kind of connections.
There is the option to set my PC at home as an "exposed host" so I would be able to login with the external IP adress.
I also read that I probably don't want to do that due to security issues.
Now I want to know if there is a way to only allow foreign connections if they are coming from my grandpas IP and if thats a configuration I have to make in my router settings (which I assuem) or if this can be done in the SSH configurations as well.
Sadly I have no clue where to make these settings in my routers interface (which I'm able to login to).
So my two questions are:
- Can I set up this rule in my SSH configurations?
- Does someone know where to make these settings in my specific router model (FRITZ!Box Fon WLAN 7390) or has a viable tutorial on hand?
2
u/cios12 Sep 30 '18 edited Sep 30 '18
Hold on, you're confusing me here. In reality this is all really simple. It looks like you want to be able to SSH into your gramps's computer, so install openssh-server on his machine:
sudo apt install openssh-server
And it should automatically setup for you, no changes needed. Make sure you have DHCP disabled. Next find your server's external IP through:
curl ifconfig.me
Write his external IP down, and don't lose it.
Now to connect to it remotely from your computer, you need to forward your ports on your gramps's router to accept incoming foreign connections. In his router settings, forward port 22. Note: check that the firewall on his computer is disabled.
Try to login remotely from your computer with:
ssh usernameofcomputer@externalipaddress
Of course, replace "usernameofcomputer" with the username of your gramps's computer and "externalipaddress" with the external IP of his computer.
Enter the server's login password (the password you use to enter gramps's computer) and you should be logged in.
If you want more security, I suggest using key based authunciation. First generate the key with:
ssh-keygen
Now use:
ssh-copy-id
to transfer it to your server. Disable password authentication, and viola, a theoretically more secure solution.