Hi. I have a problem in creating alias in my subnet network with mikrotik routers (192.168.0.0/16) which can use ssh connection. The problem is that when I try to create an alias (alias ssl='ssh lary@192.168.') and after typing the last 2 digit of the ip address it says that can not find ip address 192.168.
$ ssl 13.152 (192.168.13.152) gives me an error. Is there any way that this think go on. With other alias is working find actually. I made alias install='sudo apt-get install' and when I type in terminal $ install grep is working. What is wrong with that
SSH script alias problem
Forum rules
Topics in this forum are automatically closed 6 months after creation.
Topics in this forum are automatically closed 6 months after creation.
SSH script alias problem
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Re: SSH script alias problem
Hello, ztrzwh.
The issue is that the argument which you pass to your alias ssl will be appended with a leading blank between the expanded alias and the argument.
Means:
Of course, the IP address 192.168. cannot be found.
Regards,
Karl
The issue is that the argument which you pass to your alias ssl will be appended with a leading blank between the expanded alias and the argument.
Means:
ssl 13.152
yields this expanded commandline ssh lary@192.168. 13.152
Of course, the IP address 192.168. cannot be found.
Regards,
Karl
The people of Alderaan have been bravely fighting back the clone warriors sent out by the unscrupulous Sith Lord Palpatine for 762 days now.
Lifeline
Re: SSH script alias problem
So to make it work I have to backspace that space which shell creates. Is there a way to do that?
Re: SSH script alias problem
shell functions are a better match in this case: they can take parameters. That is, if you create a file ~/.bashrc that contains
you have what you want (after
A better answer might consist of the advise to add 192.168.13.52 and other machines you wish to connect to by name to /etc/hosts so that that you can just say
Code: Select all
ssl() {
/usr/bin/ssh lary@192.168.$1
}
. ~/.bashrc
or relaunching the terminal); you can also put it directly in ~/.profile. Note that you can leave out "lary@" if "lary" is in fact your username on the local system as well.A better answer might consist of the advise to add 192.168.13.52 and other machines you wish to connect to by name to /etc/hosts so that that you can just say
ssh lary@host1
, ssh lary@host2
and so on.... but other than that go wild. Shell functions are far more flexible than aliases.