Setup SSH server by hostname?

3

I am a newbie in networking and I am trying to setup a SSH server, so that I can access the files on my host. I used openssh-server to successfully setup and connect to the server (on LAN).

While connecting, I use my IP address: e.g. ssh username@10.139.55.14 etc.

Now the problem is, my host gets the IP address dynamically, so every time I restart my host machine, the SSH server will have a different location (IP address).

I tried using avahi-daemon and could not connect using my hostname.

I have 2 questions:

If my host is on the same network, how can I access it using the hostname (I don't want to enter the IP address while connecting)?

If my host machine is on my home network, how can I access it from my Work network?

I remember, on Windows, if my host and client are on the same network, I can simply connect using the hostname.

.

The basic idea is I could have my host machine at

(a) Work (LAN) where I cannot access the router.

(b) at home (Using the internet) .

I want to access the host machine, without using the IP address. And I want to access all the files on my host machine. Is there any easy solution to this?

tabs_over_spaces

Posted 2016-03-21T18:44:05.860

Reputation: 33

When you say "my host gets the IP address dynamically, so every time I restart my host machine" Are you just talking about your linux machine? – SeanClt – 2016-03-21T19:14:42.410

Answers

1

So what you need to do is take advantage of a service like Dyn DNS.

This will cause your server to periodically update the DNS records to point to your servers dynamic IP address.

Josh Beauregard

Posted 2016-03-21T18:44:05.860

Reputation: 156

When DynDns was being difficult about keeping accounts active, basically shutting down a hostname if the right hoops were not jumped through, my backup method was to have the home machine send an email periodically to a free email account hosted at gmail. If my home IP had changed, and DynDns had stopped working, I could always go to the gmail account and look at the email. I put the IP address in the email body, but I could have just looked at the original headers too. I have not checked, but I suspect DynDns is even more difficult these days than then. – infixed – 2016-03-21T21:38:14.837

well, now, DynDNS is paid, and my router (Netgear 3000 NAS100) does not support any other DDNS provider (like No-IP) I need to change the router or buy the DynDNS subscription. Is there any other (free) way?

I really appreciate your help. – tabs_over_spaces – 2016-03-28T18:12:49.850

0

I assumed when you said my host, you mean your linux box

  1. Set a static IP on your Linux box so you have a static IP

  2. on your Router Enable DDNS, DynDNS is no longer free, i personally use http://www.noip.com. this would give you a public hostname like yourname.noip.com

If you router doesn't support no-ip then you can flash it with DD-WRT, DD-WRT supports no-ip.com

  1. Change SSH port from default 22 to something in the five digit like 55555. using default is very insecure

  2. Forward your port SSH port to your Unix Box. I take it that would be the new static local IP you have from Step 1

SeanClt

Posted 2016-03-21T18:44:05.860

Reputation: 1 960

well, now, DynDNS is paid, and my router (Netgear 3000 NAS100) does not support any other DDNS provider (like No-IP) I need to change the router or buy the DynDNS subscription. Is there any other (free) way?

I really appreciate your help. – tabs_over_spaces – 2016-03-28T18:14:02.007

Flash Netgear 3000 with DD-WRT, this is the one i use it support noip and many others – SeanClt – 2016-03-28T18:18:29.103