ssh 远程执行命令/remote 执行
列举一些常见的 ssh 远程执行命令的方法
cheatsheet
Various ways to execute commands remotely using SSH.
Purpose | Syntax | Examples |
---|---|---|
Single-line ssh command 单行命令执行 | ssh $user@$host command |
|
Executing several commands 多条命令执行 | ssh user@server "command1; command2; script1" |
|
Running a command with sudo 带 sudo 的方式执行命令 | ssh -t user@host sudo command |
|
Run commands from a local file | ssh user@hostname < file |
|
Use Heredoc bash feature to run many commands | ssh -T $HOST << EOL |
|
Multi-line command using Heredoc when you need to assign variables | ssh -T box1<<'EOL' |
|
参考