Contents
How do I run a command on a remote server using SSH?
A few ways to execute commands remotely using SSH
- Single-line command. Executing a single command: ssh $HOST ls. …
- Simple multi-line command. VAR1=”Variable 1″ ssh $HOST ‘ ls pwd if true; then echo “True” echo $VAR1 # <– it won’t work else echo “False” fi ‘ …
- Multi-line command with variables expansion. …
- Multi-line command from local script. …
- Multi-line command using Heredoc.
How do I run a command on a remote server?
Run command on remote server via ssh
- If you need to run a command or shell script on a remote server via ssh. …
- ssh <username>@<hostname> ‘<commands>’
- ssh command uses three mandatory input,
- username = username to login to remote system.
- hostname = Remote system name or ip address.
- commands = single command or list of commands seperated by semicolon.
15 дек. 2017 г.