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.

3 Answers 3


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/
  • Or more simple ssh user@$(runMyScript), where the script just outputs the ip address.
    – ott--
    Commented Feb 19, 2013 at 14:39
  • Or you can point the script at a different file and Include it from your ~/.ssh/config. Commented Nov 28, 2022 at 22:16

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.


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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .