1

Is it possible to label port and use the label name instead of the port number in SSH port forwarding?

For example, a normal ssh port forwarding would be:

ssh -L 5432:localhost:5432 remotepc
ssh -L 8081:localhost:8081 remotepc

But is something like below possible?

ssh -L postgres:localhost:postgres remotepc
ssh -L my_app_server:localhost:my_app_server remotepc

Thanks.

1 Answer 1

2

Yes, ssh will accept service names defined in the /etc/services table. Your OS already has some entries there (mostly unused), but you can add your own.

(For Windows this is \Windows\System32\drivers\etc\services, just like the hosts file.)

Note that the file might already contain 5432, under the official IANA name postgresql. In that case you can add shorter aliases at the end of the same line:

postgresql 5432/tcp postgres psql

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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