问题原文
原帖链接 · Jason Swett · CC BY-SA 4.0
The question I have is vague, but it's vague on purpose because I don't want to bias the answers toward a needlessly specific solution.
Let's say I have Linux servers A and B, where server A has a web application on it and server B doesn't.
Let's say I want server A to tell server B to execute a certain set of shell commands. Because I imagine someone will ask, let's say that the commands I want to run are:
mkdir /var/www/git/repo-1.git
cd /var/www/git/repo-1.git
git --bare init
What's the simplest way I could get server A to tell server B to execute these commands?
FWIW, security IS an important factor in whatever solution I use.
已采纳解答
原帖链接 · v25 · CC BY-SA 4.0
You didn't specifically mention that the commands are to be invoked from the web-app, so I'll assume that's not the case, as this would make the question more 'solution specific'.
The simplest method, assuming you have ssh access.
Do this on the terminal of serverA:
$ cat > script.sh
cat /proc/sys/kernel/hostname
^C
$ scp script.sh serverB:~
script.sh 100% 31 9.8KB/s 00:00
$ ssh serverB 'sh ~/script.sh'
serverB
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
