Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have an server that has a dynamic IP address and is accessible over SSH. On the server, a script uploads a text file containing the server's public IP address to a web location whenever that address changes.

How can I connect from to the server from some other client? This would be similar to DynDNS, but using the web to obtain the IP address.

share|improve this question
up vote 3 down vote accepted

If you don't have access to or can't use a DynDNS service, create an alias in ~/.ssh/config and edit the IP address whenever it changes. Put these two lines (optionally followed by other settings for that host alias) in ~/.ssh/config:

Host nickname
CheckHostIP no
HostKeyAlias nickname

Run this script whenever the address may have changed.

ip_address=$(wget -q "$url")
case $ip_address in
  '') :;; # empty file or connection error
  *[!.:0-9A-Fa-f]*) # bad character
    echo 1>&2 "The content at $url doesn't look like an IP address!"; exit 1;;
  *) # this looks like an IP address
    ed -s ~/.ssh/config <<EOF
/^ *Host  *nickname
/^ *HostName 
s/e .*/e $ip_address/
share|improve this answer
Or more simple ssh user@$(runMyScript), where the script just outputs the ip address. – ott-- Feb 19 '13 at 14:39

You can use the nsupdate command to do a Dynamic DNS update to the remote server. I'm assuming, but it's not clear, that you're comparing the (free) commercial service offered by DynDNS against "something else". It turns out that "dynamic DNS" is actually a standardized protocol for updating records. You don't need to move around a .txt file with a record in it (though that could work too). You can instead use nsupdate to update an entry in a live zone instead.

share|improve this answer

Why don't you simply update your DNS entries with that IP?

I'm doing this using ssh-dyndns. See the description in my blog entry.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.