以下SSH命令可用于远程创建文件。
$ssh user@hostname '( cd /tmp/&& touch ssh_file.txt )'
此示例将使远程/etc/passwd
文件的本地副本到/tmp/passwd
:
$ssh user@username '( cat /etc/passwd )' > /tmp/passwd
此示例将在远程服务器上执行脚本。当然,只有脚本已存在并且具有正确的可执行权限,才能有效。
$ssh user@hostname '( cat ~/myscript.sh )'
在此示例中,我们将远程服务器的/var/log/auth.log
文件的本地副本进行到/tmp /
目录中的本地文件:
$ssh user@hostname '( cp /var/log/auth.log /tmp/; cd /tmp/&& tar -jcvf - auth.log )' > /tmp/auth.tar.bz2
日期:2020-07-07 20:56:07 来源:oir作者:oir