How to use sudo from within Windows GUI clients bypassing tty
Solution 1
What the basic problem here is that there is a protection again non-human input. TTY ensures that the action is performed from keyboard actions, and not from another program. Now there is a way around this.
If you have access to the sodeors file you can deal with this. It is not really recommended but here goes, this is really a way that works.
You open the file /etc/sudoers
and you find the following line:
Defaults:myusername !requiretty
This tells the the system that the user myusername
can perform non-keyboard actions. Now you can work with all your files using the sudo command.
Best is to try to avoid this.
Solution 2
When dealing with Amazon Web Services and WinSCP the adjusting the sudoers keyboard input status does not work because WinSCP continues to throw a SSH command that AWS does not understand and will give a bash error.
I was having the same problem and solved it using the steps in this tutorial:
How to Login in as SSH root user from WinSCP to AWS
Solution 3
With WinSCP, check the "Avanced Options" box. In the Environnement>SFTP section, select the "sudo su -c /bin/sftp-server" option.
Indeed, your SSH server has to be configured to allow you lauchning such command.
Solution 4
You have to consider to log in as your root user on the server rather than using su
or sudo
, this could be done by username or password or via a key file. However, the server should allow you to do this; if not, there is not much that you can do to remotely gain root acces...
Related videos on Youtube
![Codium](https://i.stack.imgur.com/FhFqn.jpg?s=256&g=1)
Codium
Updated on September 18, 2022Comments
-
Codium almost 2 years
I need to copy files via ssh but I am getting permission denied.
How can I log as a root by windows clients such us FileZilla/WinSCP?
I try execute command:
sudo su, but I am getting error: You must have tty to run sudo.
I try to resolve this error but without luck.
-
Admin almost 13 yearsA little trick is you can use /tmp as a temporary place and then move the files from it, beware of security and space limitations though.
-
Admin about 10 yearsFor WinSCP, see How to change user in winSCP?
-
-
user2956477 almost 13 yearsI logged in by key/username which I get from my boss, but it gives me nothing at all, I can't copy files at all
-
Olli over 10 yearsYou could post the summary without screenshots. Posting just a link is not a good practice.
-
Martin Prikryl about 10 yearsFor more details, see winscp.net/eng/docs/faq_su
-
Martin Prikryl about 10 yearsTurning off keyboard-interactive authentication is irrelevant, imho. It has nothing to do with TTY. And it affects SSH authentication phase only.
sudo
's turn is only after SSH authentication phase. Read about keyboard-interactive authentication. -
Martin Prikryl about 10 yearsThis does not answer the question, which is about a problem with tty.
-
Martin Prikryl about 10 yearsOnce you setup the
requiretty
flag as this answer explains, follow this guide to setup WinSCP to usesudo
: winscp.net/eng/docs/faq_su -
Yasiru G almost 8 yearsi'm facing the same problem and thank god I found something here :) One question, what are the command that this will need to allow from sudo config?