Ssh – Upload file over ssh and execute command on the remote machine

file-copyssh

I am trying to find the simplest way to upload a file using ssh and after that run a command on the remote machine within the same ssh session for some post-processing, so that I don't need to login again. The upload should, if possible, show some progress indicator.

So far I looked into scp and rsync, and both are not capable of running any hooks. (I could use the --rsync-path parameter to execute some script before rsync) but I want to do post-processing. Is there any way to open a ssh session, upload, execute a command and close it again?

Best Answer

You might want the ControlMaster mechanism in ssh.

Related Question