简体   繁体   English

在一个脚本中使用ssh和scp

[英]to ssh and scp in one script

I perform ssh to remote server to run a backup script. 我对远程服务器执行ssh以运行备份脚本。 Then scp it to local machine. 然后将其scp到本地计算机。

1. ssh root@Remoteserverip sh ~/folder/backupscript.sh
2. scp root@Remoteserverip:/backupfolder/file.tgz /localfolder/

Is there any way to script these two operations in one script? 有什么办法可以在一个脚本中编写这两个操作的脚本?


Ps: couldn't find solution elsewhere. 附:在其他地方找不到解决方案。

Why not? 为什么不? Just put those commands in the script and thats it. 只需将这些命令放在脚本中即可。

ssh root@Remoteserverip sh ~/folder/backupscript.sh
scp root@Remoteserverip:/backupfolder/file.tgz /localfolder/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM