Reputation: 2160
We have a server that is set up so you can't log in with root directly. You first log in with a user, then run su and enter the password.
I need to SSH into a server, using phing, and sudo then run a command. I thought if I can get it working just via ssh
, I can use that command in an exec task in phing, but can't even get the plain SSH right.
Is this possible?
I've tried the following:
ssh user@server 'su && cd /var/www/clients'
ssh user@server 'su && {{password}} && cd /var/www/clients'
Upvotes: 0
Views: 104
Reputation: 596
You can use the SshTask and how-to-pass-the-password-to-su-sudo-ssh-without-overriding-the-tty.
<project name="ssh-with-later-sudo" default="run-cmd" basedir=".">
<target name="run-cmd">
<ssh username="user" password="password" host="server" command="echo password | sudo -S cd /var/www/clients" />
</target>
</project>
Upvotes: 1