ssh sudo to a different user execute commands on remote Linux server

We have a password less authentication between the server for root user, I am trying to run the alias on remote server as below

#ssh remoteserver runuser -l wasadmin wasstart

But it is not working. Any suggestions or any other method to achieve it



answered 4 months ago runwuf #1

Based on your comments as you need to sudo to wasadmin in order to run wasadmin, you can try this:

ssh remoteserver 'echo /path/to/wasadmin wasstart | sudo su - wasadmin'

answered 4 months ago MohammadReza #2

For add an alias in linux you must run

alias youcommandname=‘command’

Notice: This will work until you close or exit from current shell . To fix this issue just add this to you .bash_profile and run source .bash_profile Also your profile file name depending on which shell you using . bash , zsh ,...

comments powered by Disqus