3

I need to connect to a remote server without the use of a password but using a public keyfile using the Python module Paramiko.

How can I do this?

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
nour
  • 105
  • 8

1 Answers1

2

Use key_filename argument of SSHClient.connect:

import paramiko
 
ssh = paramiko.SSHClient()
ssh.connect("example.com", username="user", key_filename="mykeyfile")

Though you need private key file for that. You cannot authenticate with public key file.


You will also need to verify the host key:
Paramiko "Unknown Server"

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992