sfreiberg/simplessh

Getting this error when doing ssh with password, sudo: sorry, you must have a tty to run sudo

avnish30jn opened this issue · 3 comments

Hi,

I am getting this error when doing ssh with password

sudo: sorry, you must have a tty to run sudo

The library doesn't currently implement a pty device as it was meant for non-interactive commands. Unfortunately sudo (with a password) requires this. I'd have to think best how to do this because I do think sudo (with password) is important but I don't want to open interactive shells.

For the time being you can either change sudo so it doesn't require a password or look at implementing a pty. Simplessh gives you full access to the ssh client. For help implementing this have a look at:

https://godoc.org/golang.org/x/crypto/ssh#example-Session-RequestPty

Also, I'd welcome a pull request.

Did a little digging and it looks like sudo can be implemented without an interactive pty but it will require some additional code and testing. I'll see if I can implement this over the weekend.

I just added a new function that will allow you to use sudo with a password. Please open a new issue if you find any bugs.