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).

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).


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 -

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.

  • Also would be nice if you tidy up your question. The title for instance could read "Getting "you must have a tty to run sudo" when using sudo from WinSCP. – Martin Prikryl Jan 6 '14 at 7:48
  • thank you for the answer, my sudoers file looks like this : Defaults:my_username !requiretty my_username ALL=NOPASSWD: ALL, and I get the same error message in log file. – user41117 Jan 6 '14 at 8:31

You need to use sudo on login setting with WinSCP

Check this WinSCP FAQ.

  • 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 6 '14 at 4:08
  • what configuration did you added on /etc/sudoers file? – pragnesh Jan 6 '14 at 4:47
  • my_username ALL=NOPASSWD: ALL This. – user41117 Jan 6 '14 at 5:32
  • try doing as per this post holisticsecurity.wordpress.com/2012/09/03/… – pragnesh Jan 6 '14 at 6:17
  • @user41117 Regarding the "Error skipping startup message", please include session log into your post. – Martin Prikryl Jan 6 '14 at 6:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.