3

I need to update httpd.conf in /usr/local/apache/conf path.

I have generated SSH key in cpanel, and selected it in Advanced options in SSH/Authentication section.

Also I have tried two different SCP/Shell options in this section (default, /bin/bash, sudo su -)

And as I file protocol I select SCP.

And I can login but, am getting permission denied message that I can not edit or download file. I have also tried to set 777 for folder and 664 for files, but it is also not letting me to do this change.

I am using Centos 6.5.

Session log :

2014-01-06 08:23:13.128 Using SCP protocol.
. 2014-01-06 08:23:13.128 Doing startup conversation with host.
. 2014-01-06 08:23:13.182 Skipping host startup message (if any).
! 2014-01-06 08:23:13.182 stdin: is not a tty
! 2014-01-06 08:23:13.182 sudo: sorry, you must have a tty to run sudo
. 2014-01-06 08:23:13.182 Server sent command exit status 1
. 2014-01-06 08:23:13.182 Disconnected: All channels closed
* 2014-01-06 08:23:13.241 (EFatal) **Connection has been unexpectedly closed.** Server sent command exit status 1.
* 2014-01-06 08:23:13.241 Error skipping startup message. Your shell is probably incompatible with the application (BASH is recommended).
kasperd
  • 29,894
  • 16
  • 72
  • 122
user41117
  • 129
  • 1
  • 4

3 Answers3

4

I want to share my solution because I'm also searching several time for a workaround. I'm using CentOS7 right now and try to get connetion via WinSCP (Pubkey Auth).

sshd_config

..
RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile  .ssh/authorized_keys
PasswordAuthentication no
UsePAM yes
..

@CentOS visudo - add following 2 entrys

username ALL=NOPASSWD: /bin/su
Defaults:username !requiretty

WinSCP settings:

Disable keyboard-interactive @ SSH authentication settings solves the problem for me. 
SCP settings command: sudo su -
guest
  • 41
  • 3
3

As @pragnesh has suggested, you will find all the instructions in WinSCP FAQ How do I change user after login (e.g. su root)?

Not only you need to add the sudo -s shell and yourusername ALL=NOPASSWD: ALL line (or similar) to the sudoers, but you also need to make sure the sudo does not require TTY.

While this is the default behavior, you may have it configured differently. Make sure you remove the requiretty option from the sudoers file.

You can also change this only per user, see sudoers: how to disable requiretty per user.

Martin Prikryl
  • 7,327
  • 2
  • 36
  • 71
0

You need to use sudo on login setting with WinSCP

Check this WinSCP FAQ.

Martin Prikryl
  • 7,327
  • 2
  • 36
  • 71
pragnesh
  • 492
  • 2
  • 5
  • Hi, thank you on response, I have take a look at a link, add a sudoers file(644 permission on a file), and content, after that I have select sudo -s as a Schell option, and I couldn't even login, I get this message now : "Error skipping startup message. Your shell is probably incompatible with the application (BASH is recommended)." And with bash option, I have permission problems. – user41117 Jan 06 '14 at 04:08
  • what configuration did you added on /etc/sudoers file? – pragnesh Jan 06 '14 at 04:47
  • my_username ALL=NOPASSWD: ALL This. – user41117 Jan 06 '14 at 05:32
  • try doing as per this post http://holisticsecurity.wordpress.com/2012/09/03/open-files-ubuntu-root-from-winscp-remotely/ – pragnesh Jan 06 '14 at 06:17
  • @pragnesh, thank you, I tried that, now I get this error : Cannot initialize SFTP protocol. Is the host running a SFTP server? I have google it out, end up here http://winscp.net/forum/viewtopic.php?t=2918, tried everything, and still nothing. :( – user41117 Jan 06 '14 at 07:16