1

How to convert this ruby piece to python?

Net::SSH.start(machine, "ubuntu", {:keys => [ssh_key]}) do |ssh|
  ssh.open_channel do |ch|
    sent_cmd = false
    ch.request_pty do |ch,success|
      ch.exec( "sudo su -" ) do |ch, success|
        raise "fail" if( !success )
      end
    end
  end
end

I have done this so far:

ssh_key1 = paramiko.RSAKey.from_private_key_file( ssh_key, 'r' )


session = paramiko.SSHClient()
session.set_missing_host_key_policy( paramiko.AutoAddPolicy() )

session.connect( machine, port = 22, username = 'ABC', pkey = ssh_key1 )

How to do open.channel in python?

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.