Loading ...
Sorry, an error occurred while loading the content.
 

Methods that works to SSH and sudo.

Expand Messages
  • josegarciajunior
    Guys, I need to be able: - establish ssh connection to a server - sudo to another user (sudo su - owner_user). In some cases prompt for passwords and others,
    Message 1 of 1 , Jan 30, 2007
      Guys,

      I need to be able:
      - establish ssh connection to a server
      - sudo to another user (sudo su - owner_user). In some cases prompt
      for passwords and others, no.
      - run a process using owner_user
      - and get results this execution.

      I already try with:

      Net::SSH::Perl - Always hang when I run sudo.
      Another problem, looks like that session doesnt persist. Ex: I send a
      command: "cd /" and after, send "pwd", im always get "/home/userdir/"
      instead "/".

      My connection string:
      $ssh = Net::SSH::Perl->new($host,
      cipher => Net::SSH::Perl::Cipher::name(3),
      port=>$port || 'ssh',
      interactive=>1,
      use_pty=>1,
      protocol=>2,
      debug=>0) or erro;
      $ssh->login($user, $pass);
      -----

      IPC::Session - WORKS REALLY GREAT... But I cant treat with password's
      prompts. Im trying to treat login password. With "sudo" I get no
      prompt to try expect. I need to be able to expect login password and
      sudo password, if asked.
      ---

      Expect - I had tried but no successful. I found some messy examples.
      --

      All sugestions will be welcome!
    Your message has been successfully submitted and would be delivered to recipients shortly.