This question already has an answer here:

create unix alias for "ssh username@", and I would like to use it for any ip address.

for example, alias go="username@" usecase: $go ; implement => ssh username@

Currently if i do $go, it is taking extra white space between @ and ip address. how can i remove it?

marked as duplicate by user4556274, Christopher, Satō Katsura, LinuxSecurityFreak, Stephen Rauch Nov 7 '17 at 14:49

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 3
    you are aware you can configure a default outgoing user in config in .ssh ? – Archemar Nov 7 '17 at 14:32
  • You might want to add an explanation for why you specifically want to use an alias instead of some other method. Specifically, you might want to explain why the ~/.ssh/config file doesn't solve your problem. – igal Nov 7 '17 at 14:34

Here is a solution using a function instead of an alias:

function go() {
    ssh "username@$1"

But are you sure that this is what you want? Have you considered using your ~/.ssh/config file? To override the default user name and set it to username you could add the following stanza:

Host *
    User username

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