I would like to know how can I run shell commands in a remote machine. I tried this:
ssh prdcrm1@${server} "grep -l 'Sometthing' *"
It is working, but I want to run more commands. Do someone has an Idea?
I would like to know how can I run shell commands in a remote machine. I tried this:
ssh prdcrm1@${server} "grep -l 'Sometthing' *"
It is working, but I want to run more commands. Do someone has an Idea?
You can run multiple commands on remote machine like,
Run date and hostname commands:
$ ssh user@host "date && hostname"
Run a script called /scripts/backup.sh
ssh user@host '/scripts/backup.sh'
Run sudo or su command using the following syntax
ssh user@host su --session-command="/sbin/service httpd restart"
ssh -t user@host 'sudo command1 arg1 arg2' ## su syntax ##
Multi-line command with variables expansion
VAR1="Variable 1"
ssh $HOST bash -c "'
ls
pwd
if true; then
echo $VAR1
else
echo "False"
fi
'"
Hope these helps you.