0

For example, I have the code below:

cmd = "ssh <host>"
os.system(cmd)

How I can send the password in the python script so that I don't have to type the password every time?

injoy
  • 3,993
  • 10
  • 40
  • 69
  • 1
    Were you wanting to implement using an agent? Check out http://rabexc.org/posts/using-ssh-agent. After the image of agent Smith it gives a good example of running an ssh-agent. – Luke Jul 17 '15 at 02:35

1 Answers1

0

Use paramiko, like so:

sh = paramiko.SSHClient()
sh.connect(server, username=username, password=password)

There are also many good demos in the paramiko github repo.

Maelstrom
  • 443
  • 2
  • 9