I regularly have to deploy stuff via scp. The problem is that the user on the remote machine (e.g. tomcat) does not match the user i am logging in with (e.g. mylogin). And almost always I cannot login directly with the remote user (disabled from the admin)
Assume the following: I want to deploy a file into tomcats' webapps folder but can do this only via 'sudo -U tomcat' on the remote machine before.
At the moment I am doing sth. like this:
scp file.war [email protected]:/home/mylogin/tmp/
ssh [email protected] 'sudo -U tomcat cp /home/mylogin/tmp/file.war /tomcat/webapps/'
Is there a better solution without the temporary folder? I mean, is it possible with only one copying with a sudo "in-between"? Can this be done with portforwarding?
This question is related to this