How to Enable Alias Command on Remote Machine Using SSH
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
How to Enable Alias Command on Remote Machine Using SSH
Hi,
I basically want to run my alias commands on a remote machine via SSH. So, if I do this, ssh test_machine "find_me" (where find_me is an alias command), it will give me this error.
I basically want to run my alias commands on a remote machine via SSH. So, if I do this, ssh test_machine "find_me" (where find_me is an alias command), it will give me this error.
ksh: find_me: not found
How do I solve this?
uhm, maybe a stupid question but just to make sure, have you aliased the commands on the remote machine? Just because you have them set as alies on the machine you're logging in from doesn't mean you have the alias set on the remote machine, since you log in to the remote, i.e. start a new session there. Or have I misunderstood you?
Yes, the command has been alias on the remote machine. So, if I log to the remote machine and I ran "find_me", then it will perform the command.
What I want is to run the command: ssh test_machine find_me, and it will run the command without me needing to log to the machine anymore. This is like if I type ssh test_machine ls, it will list the files but this isn't a problem because ls is not an alias command.
Yes, the command has been alias on the remote machine. So, if I log to the remote machine and I ran "find_me", then it will perform the command.
Note that the rc files read are usually not the same if you use a login shell instead of a non-login one.
For example, bash reads ~/.bashrc when opened as an interactive non-login shell, but it reads ~/bash_profile instead if it's ran as a login shell. Read "man bash" for complete info.
I don't know anything about ksh, but "man ksh" or "info ksh" probably have some tips on this.
Alternatively, you can try to rewrite them as functions or scripts if that doesn't hepl.
So, if the remote machine uses bash. And I put the alias command in .bashrc, then theoretically it should work (ssh to the remote machine and run an alias command), right? Is this what you mean?
So, if the remote machine uses bash. And I put the alias command in .bashrc, then theoretically it should work (ssh to the remote machine and run an alias command), right? Is this what you mean?
Yes, bashrc will be read. But as I said, I am not sure that aliases will work because of their nature. Functions should, though. So, at it worst, you might need to rewrite the alias as a function, which is trivial enough.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.