I need to access some Linux server behind NAT (no ports forwarded), so I need to have something like "phone home" like Teamviewer has. There is no GUI, but somebody can log in through SSH and dictate a password if it is changing (like Teamviewer). SSH (port 22) is enough (I can tunnel ports through SSH if I need). Any suggestions? How safe is it?
What you need is called 'reverse SSH tunnel'. You establish an outgoing SSH session from your server to an outside machine, and then you connect from remote location to that outside machine which binds these two SSH sessions together, so you can reach your server.
There's a number of articles describing this setup, like Bypass Firewall and NAT with Reverse SSH Tunnel
Convenient options have come up in the meantime..