1
votes

On my Windows computer I use SSH-Session module on PowerShell and I want to use sudo in order to execute special command in my server.

But when I launch my sudo command through SSH-Session I have this error:

sudo: no tty present and no askpass program specified

I don't want to use PuTTY or the ssh command, so the parameter -l is not the issue!

If it's possible I don't want to change the SSH server configuration.

I want to know how to force the pseudo allocation tty in PowerShell?

Thanks

2
Are you permitted to modify your sudoers file to allow a specific setting for this user? Basically SSH-Session is based on SSH.NET (sshnet.codeplex.com). From what I know it doesn't support enabling psuedo-tty's (which I believe would solve this problem). So what you need to do is detailed in this answer: unix.stackexchange.com/a/80159/1347 (I think... :) ) - Kev
In Linux console I can execute my sudo command with the same user without problem. I think it's not necessary to update sudoers file but an option (if it exists) on PowerShell - general03

2 Answers

1
votes

The SSH-Session module is based on SSH.NET library.

The SSH.NET library does support pseudo terminal allocation, but the SSH-Session module does not expose the functionality.

You would have to modify SSH-Session code to make it available.

  • Either use the Shell class (SshClient.CreateShell), which implicitly requests pseudo terminal.

  • Or explicitly request pseudo terminal using the ChannelSession.SendPseudoTerminalRequest.


Or modify your sudoers configuration file not to require pseudo terminal for sudo (remove the requiretty option, which is off by default, by the way).


Or use SSH.NET directly, without the SSH-Session module.

See these questions for some code:

0
votes

You can now use the Open SSH exe, push by Microsoft here.

After launch PowerShell as administrator

ssh 192.168.1.123 -p 22 -l general03