I want to set an alias so that I can swiftly log in to one of my workstations. For example, I must enter

ssh [email protected]

to log in to one of my machines. Sometimes, the hostname could be c1232-node2 or c1232-node3, but the domain name would always be example.com.

I want to add the alias permanently in my .zshrc file so that I need not set it every time I open the terminal.

I did my research, and I was successful using a function such as below:

ssh_node() { ssh root@"$1".example.com; }

But when I add this function into my .zshrc and run the source command on it, it complains and doesn't accept the function.

Thanks in advance for the help!

1 Answer 1


So dumb of me. I achieved my goal by adding this line to the .zshrc:

cluster() { ssh root@"$1".example.com; }

And then did a

source .zshrc

Running cluster c1232-node3 executes ssh [email protected]. Mission complete!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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