LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   WinSCP, sudo & SFTP: can't get them all working together (https://www.linuxquestions.org/questions/linux-newbie-8/winscp-sudo-and-sftp-cant-get-them-all-working-together-4175441092/)

Glop 12-12-2012 03:49 AM

WinSCP, sudo & SFTP: can't get them all working together
 
Complete beginner here.

I'm using Ubuntu 12.10, trying to allow WinSCP to connect with root access (I'm using keys, not passwords). I've been following the steps in the WinSCP FAQ, and this post:

Quote:

I fought with this today and came up with the following solution:

Add a line to your sudoers file:
username ALL=NOPASSWD: /usr/lib/openssh/sftp-server

Then in the SFTP setup section of WinSCP edit the session SFTP server:
sudo /usr/lib/openssh/sftp-server

Boom, root access to file system via WinSCP.
HTH,
Clint
from a thread on the WinSCP forums.

I've added the line to my sudoers file so it looks like this:
Quote:

# User privilege specification
root ALL=(ALL:ALL) ALL
chris ALL=NOPASSWD: /usr/lib/openssh/sftp-server
and I've set up the SFTP in WinSCP as directed.

Connection and authentication seems to work fine until trying to use sudo. WinSCP gives me this message after the key is authenticated:
Quote:

Cannot initialize SFTP protocol. Is the host running a SFTP server?
My auth.log shows this:

Quote:

sshd[3070]: Accepted publickey for chris from 27.xxx.xxx.xxx port 51868 ssh2
sudo: pam_unix(sudo:auth): conversation failed
sudo: pam_unix(sudo:auth): auth could not identify password for [chris]
sshd[3079]: Accepted publickey for chris from 27.xxx.xxx.xxx port 51899 ssh2
sudo: pam_unix(sudo:auth): conversation failed
sudo: pam_unix(sudo:auth): auth could not identify password for [chris]
I've also tried changing the additional line in sudoers to
Quote:

chris ALL=NOPASSWD: ALL
with the same results.

Connecting without trying to use sudo works fine.

Can anyone let me know how I'm messing this up? Seems it should be fairly simple, but it's been causing me quite a few headaches.

Thanks

Glop 12-12-2012 11:28 AM

Found the problem. In case anyone else happens to experience the same thing, the line:
Quote:

yourusername ALL=NOPASSWD: /usr/lib/openssh/sftp-server
needs to go under the admin group section like so:
Quote:

# Members of the admin group may gain root privileges
%admin ALL=(ALL) ALL
yourusername ALL=NOPASSWD: /usr/lib/openssh/sftp-server
not under the user privilege specification.


All times are GMT -5. The time now is 06:54 PM.