都是linux機器
1.在 host a 執行指令 a.sh, 然後 ssh 到 host b
2.在 host b 執行指令 b.sh, 然後 ssh 到 host c
3.在 host c 執行指令 c.sh, 然後 ssh 到 host d
4.在 host d 執行指令 d.sh, 結束
note:
a 跟 c,d 不相連
b 跟 d 不相連
請問 bash 如何寫? thanks.
https://gist.github.com/derekp7/9978986
我實測了一下沒有問題:
HOSTB=192.168.0.4
ssh-keygen
ssh-copy-id -i ~/.ssh/id_rsa.pub YOURID@${HOSTB}
ssh YOURID@${HOSTB}
ssh-keygen
ssh-copy-id -i ~/.ssh/id_rsa.pub YOURID@${HOSTC}
helloB() { #$HOSTB
echo "Hello, world, I'm coming from $(uname -r)."
HOSTC=192.168.0.3
helloC(){ #$HOSTC
echo "Hello, world, I'm coming from $(uname -r)."
}
ssh YOURID@${HOSTC} "$(declare -f helloC); helloC"
}
ssh YOURID@${HOSTB} "$(declare -f helloB); helloB"
我跑出的結果:
YOURID@soft-router:~$ uname -r
4.4.0-19041-Microsoft
YOURID@soft-router:~$ ssh YOURID@${HOSTB} "$(declare -f helloB); helloB"
Hello, world, I'm coming from 5.8.0-38-generic.
Hello, world, I'm coming from 5.8.0-43-generic.
YOURID@soft-router:~$
可以看到三台的kernel都是不同版本
http://picasaweb.google.com/HsiuChe.Shih




























































































