I'm working a lot with SSH connections to servers, by for example forwarding localports or just establishing SSH connection to manage some servers.
For this I would like to be able to create some terminal shortcuts for example:
connect ssh server1
-->should run command: ssh xyx@xy
connect ssh server2 forward
-->should run command: ssh -NC user@xy -L 9999:localhost:3306
Is there a way to specify custom terminal commands?
Best Answer
Simply add aliases in ~/.bash_profile:
If the file .bash_profile doesn't exist:
Then add aliases with
nano ~/.bash_profile
. Examples:Then source the file or restart Terminal.app:
Entering
ssh01
in the shell will then executessh xyx@xy
orssh02
the second command.The alias (i.e. ssh01) mustn't be another valid command in your path (e.g ssh-add)