Unable to "sudo su" using WinSCP/Powershell
Hello,
I'm using Powershell/Winscp to write an automated script for deployment.
However, I'm facing a stumbling block when trying to "sudo su". Here are the steps I've donw:
1. /etc/sudoers: Commented the line Defaults requiretty
2. /etc/sudoers: Added <username> ALL=(ALL) NOPASSWD: ALL
3. In putty under SSH, I have added /bin/bash -c 'sudo su -'and it directly logs me in as root without asking for password.
The following is the snippet of the script. I have commented on the line of the script thats not working:
After about a minute, I get the following exception:
Am I doing something wrong here? Can you please throw some light on this? I'm using WinSCP v5.13
Regards,
Rakesh
I'm using Powershell/Winscp to write an automated script for deployment.
However, I'm facing a stumbling block when trying to "sudo su". Here are the steps I've donw:
1. /etc/sudoers: Commented the line Defaults requiretty
2. /etc/sudoers: Added <username> ALL=(ALL) NOPASSWD: ALL
3. In putty under SSH, I have added /bin/bash -c 'sudo su -'and it directly logs me in as root without asking for password.
The following is the snippet of the script. I have commented on the line of the script thats not working:
$session.open($sessionOptions); Write-Host("Session established"); #works ok $session.ExecuteCommand("ls -lrt"); #lists default users files $session.ExecuteCommand("/bin/bash -c 'sudo su -'"); #Script hangs here
After about a minute, I get the following exception:
Error: Exception calling "ExecuteCommand" with "1" argument(s): "Timeout waiting for WinSCP to respond".
Am I doing something wrong here? Can you please throw some light on this? I'm using WinSCP v5.13
Regards,
Rakesh