Search code examples
network-programmingsshdyndns

Remote login to linux system, ip unkown


I will be physically sending a Linux netbook to a remote site where it will be connected to the internet. I have no idea of the public IP address.

I need to be able to securely log in to the system. What's the best way to do this? I guess it needs to broadcast an id somehow (dyndns? free options?). It all needs to be preconfigured before I send it.

I'm more than happy to research on my own, but I'd be grateful in someone could point me in the right direction.

Regards,

Update- I only need console access, and it's ubuntu


Solution

  • Because the system may be behind an NAT or firewall, there is no way you can guarantee any connectivity. Even if you did know its public IP address, it is unlikely that you would be able to initiate a connection to the box from the outside.

    So the next best thing is to have the box itself initiate a connection to one or more known servers. An outgoing connection stands a much better chance of traversing any firewalls and is essential to traversing NAT.

    To make this work, you will need a server with some process listening for connections on a fixed address and port and ready to forward your ssh sessions to any such connection. The box itself will need to periodically attempt an outgoing connection to that server, perhaps hourly.

    The simplest would be to have an /etc/rc.init script (or whatever is the equivalent on your particular linux distribution) which periodically tries to establish an ssh tunnel. It might look something like:

    ssh -i remotekey.pem -R 33333:localhost:22 [email protected]
    

    This assumes you've setup "user" for key based login using "remotekey.pem" on your server. Then from your server you would log into the remote box using

    ssh -p 33333 boxuser@localhost
    

    This assumes "boxuser" is a valid user on your remote box.