Automate ssh port forwarding using DNS

Solution 1:

You can configure all this stuff inside the ssh config file, usually found at the location: $HOME/.ssh/config

for example:

Host abc
    Hostname 1.2.3.4
    Port 345
    IdentityFile /path/to/id_rsa
    LocalForward 8888 localhost:8888
    User root
Host def
    Hostname 2.3.4.5
    User root
    LocalForward 8889 localhost:8889

This way, you just need to type ssh abc and all your settings you specify inside there will get applied. Available Options found inside the man page.