I have more than one alias in my .zshrc file, but only one will not resolve.
I can connect using the IP address, but the alias will not work.
I have the same format for all of the computer aliases:
alias computername=‘username@192.168.1.xx’
As a note, I have reinstalled the OS, Manjaro 22, and this occurred previously on the same computer.
The other computers on my network has aliases as well and they all work fine.
Why is this happening?
SSH is running fine, NFS is running fine. All aliases are in the .zshrc file.
I guess you try to use ‘computername’ as argument for a command and not as a command itself.
If you take a look in
man alias
… there is your awnser.
If you run ‘ssh computername’ you will get the resovle error while ssh says “could not resolve ‘computername’”. At this point you just can see the error. It does not see the alias-content.
If you for example use
alias ssh="ssh "
befor running 'ssh computername’ it should work.
… but @andreas85 comment would do this all without aliases in a more elegant way!
I have tried different names and i’m only using letters and numbers, no spaces. It seems it must be tied to the IP address for some unfathomable reason.
Two laptops, very similar, an HP Envy and HP Pavillion, one is AMD, the other is Intel, both have Manjaro 22, brand new installs.
I apologize but reading thru the man pages still doesn’t answer questions that I have.
Likewise searching the internet gives me a lot of conflicting information.
so, as you stated, yes, If I run ssh amd1, I get the ‘could not resolve’ output.
likewise, if I type the alias command alias , it lists all my aliases including the ones I put in the .zshrc file.
I’m not sure if I understand your example.
I assume the space after "ssh " in the parenthesis was a typo?
Are you instructing me to use the alias command to enter my alias entries as opposed to adding my aliases directly in the .zshrc file?
From researching, I was under the impression with the newer versions of Manjaro, those with Zsh as the default shell, aliases were to be added directly into the .zshrc file, so I added them manually in the .zshrc file, i did not use the alias command.
I have read so much conflicting information, but most of it is from people using older versions where bash is still the default shell and from what I have read alias are managed differently.
btw where does the alias command ‘alias’ store the alias information?
Okay, I’ll put my aliases in there, I’ve not seen that option before.
So, name the file config and add my aliases in there. I’ll give it a go.
Okay, so this is baffling.
I have two computers. On one computer, I put my aliases in the .zshrc file and everything works fine.
On the other computer, I used your way with the config file in .ssh and it still will not resolve the IP. This is the same computer that would not resolve the IP in the .zshrc file either. It won’t resolve either way.
as an aside, when I have the aliases in the .zshrc file I can type the ‘alias’ command and they appear in the alias list. if I put them in the .ssh/config file, the aliases do not appear in the alias list.
~ cat .ssh/config ✔
Host 192.168.1.1x
HostName mediaserver
User me
Port 22
Host 192.168.1.1x
HostName amd1
User me
Port 22
~ ssh amd1 ✔
ssh: Could not resolve hostname amdds1: Name or service not known
~ ssh mediaserver
Last login: Mon Jan 16 15:09:42 2023 from 192.168.1.1x
me@mediaserver:~$
“Read the man page” only works if the man pages are understood by the reader, that’s why we need help. If you see the error in our syntax, just point it out, it would reduce your workload.
btw, I understand what were trying to say now, I cannot use an alias to point at a string, it must be a command (including options). alias string=“command(& options)”
there were way too many usages of the word ‘string’ in the man pages. i thought i could use an IP in place of a command. I hate man pages, but that’s another thread.
Thanks for your help, I honestly would have never figured it out on my own
.
I figured out my syntax in the ~/.ssh/config.
I was reading an example incorrectly, everything works now.
Please remember, they pay you guys well because you have an attention to detail at a level that most people do not have. I understand you are fighting laziness and ignorance, but you’re fighting the good fight. Laziness and ignorance are terrible afflictions, particular when they are combined.
DESCRIPTION
... An alias definition provides a string value that shall replace
a command name ...
....
EXAMPLES
...
4. Set up nohup so that it can deal with an argument that is itself an
alias name:
alias nohup="nohup "
So its not possible to use an alias as argument for a command. But you can combine aliases before other arguments.
So this wont work:
alias mediaserver="me@192.168.1.xx"
ssh mediaserver
But this will work:
alias mediaserver="me@192.168.1.xx"
alias ssh="ssh "
ssh mediaserver
But as I said above. @andreas85 solution is much better.
I really do appreciate your effort to educate me, I comprehend what you are saying now, but I still cannot wrap my head around how alias ssh='ssh ’ works by simply aliasing ssh and adding a space. I will read further and figure out how this works.
In a nutshell, what had me most confused was that one alias was working fine and it was incorrect too. It led me to believe I was doing it correctly when I actually was not. Why that one alias was working I have no clue.
btw, I did use the solution provided by @andreas85 and it worked.