繁体   English   中英

通过SSH连接的Ant SCP任务

[英]Ant SCP task through SSH connection

我希望能够将我的应用程序传输到开发服务器,但是要访问它,我首先必须SSH到SSH网关,然后SSH到内部网络到适当的服务器。 我可以使用Tunnel选项使用WinSCP来做到这一点,我知道ant支持SCP任务,但是它是否通过另一个ssh连接支持它?

尽管这个问题并不完全是新问题,但我今天也遇到了类似的情况。 我的目标是在必须通过(通过另一台服务器)建立隧道的远程服务器上上传文件并运行命令。 蚂蚁有可能!

sshsession仅创建可用于其中的任务的隧道 其中的任务不会自动在远程服务器上运行,但是您可以将sshexec任务与隧道一起使用来实现该任务。 而且, scp任务现在可以通过隧道上传到远程服务器。 这是一个例子:

<sshsession host="${jumphost}" port="22" username="${user}" password="${password}" trust="true">
    <localtunnel lport="${localTunnelPort}" rhost="${targethost}" rport="22"/>
    <sequential>
        <!-- run a command on the remote server (here mkdir) -->
        <sshexec host="localhost" port="${localTunnelPort}" username="${user.param}" password="${password.param}" command="mkdir ${home}/foobar" trust="true" />
        <!-- upload a file to the remote server -->
        <scp port="${localTunnelPort}" file="test_file.txt" todir="${user.param}:${password.param}@localhost:${home}/foobar/" trust="true" />
    </sequential>
</sshsession>

有点丑陋的建议,但是您可以使用scp任务将应用程序部署到网关,然后使用sshexec任务在网关上运行脚本以将应用程序scp传输到下一个服务器吗?

暂无
暂无

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

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