0

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

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

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

  • 3
    you are aware you can configure a default outgoing user in config in .ssh ? – Archemar Nov 07 '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 07 '17 at 14:34

1 Answers1

3

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
igal
  • 9,886