Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pty for root user and sudo commands #143

Open
FrancoAguilera opened this issue Jan 29, 2018 · 2 comments
Open

pty for root user and sudo commands #143

FrancoAguilera opened this issue Jan 29, 2018 · 2 comments

Comments

@FrancoAguilera
Copy link
Contributor

FrancoAguilera commented Jan 29, 2018

I have been struggling for a few days and I can't find a proper way to perform what I'm trying to do.
this is the sequence I'm trying to perform.

  1. connect via ssh as a regular user
  2. switch to root user and execute a command with privileges, e.g.: ls /root
  3. exit root
  4. close connection as the regular user (this is optional)

I have this configuration

    sshexec: {
      test: {
        command: [
          'su',  // switch to root user
          'ls /root',  // execute command with privileges
          'exit',  // exit root session
        ],
        options: {
          host: '<%= env.host %>',
          username: '<%= env.username %>',  // regular user
          password: '<%= env.password %>',  // regular user password
          pty: true,
        }
      }
    }

from the docs:

pty boolean/object

Set to true to allocate a pseudo-tty with defaults, or an object containing specific pseudo-tty settings (see 'Pseudo-TTY settings'). Setting up a pseudo-tty can be useful when working with remote processes that expect input from an actual terminal (e.g. sudo's password prompt).

Apparently there are no ways (or examples at least) to perform what I'm searching for, but I think a use case like this wouldn't be odd to happen, so... is it possible to make achieve the above steps with this library ?, can you @israelroldan provide more information about a possible pty object configuration, and the advantages/limitations about that ?

Regards.

@seinick
Copy link

seinick commented Feb 28, 2018

I'm running into a problem now with trying to remotely manage a node "forever" task that is complaining about not being able to request a pseudo-terminal. The general workflow is to stop the NodeJS service running under forever, then sftp the new service code up, then start forever again. I may find a way around but running into the pty issue is frustrating.

@FrancoAguilera
Copy link
Contributor Author

Yes in did, and sadly @israelroldan haven't provide much information about this either, I think you won't be able to achieve that using this library, but please have a look at mscdex/ssh2#661 , hope it helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants