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
Add your public key to the authorized_keys file of the tomcat user. This will allow you to ssh as tomcat:
Have your admin set up a user for SFTP-only access (this will not enable you to use SSH by "pushing a new config", whatever that means), and install your key for you, to a user in the same Unix group as tomcat, and have the tomcat user's directory made
g+w
. Then you would do something likeThis is what the Unix group system is for, and this is what everyone did before the boneheads at Red Hat decided for some unknown reason that each user should have their own group.