I am able to ssh to a Linux box B from Linux box A using the command
ssh [email protected]
This does not require a password for the connection. I am trying to automate the same with Python Paramiko. Here is the code
import os
import paramiko
ssh_client =paramiko.SSHClient()
ssh_client.connect(
hostname="myhost.com",
username="jagan",
password=None,
look_for_keys=False
)
It gives the following error:
/lib/python3.6/site-packages/paramiko/client.py in connect(self, hostname, port, username, password, pkey, key_filename, timeout, allow_agent, look_for_keys, compress, sock, gss_auth, gss_kex, gss_deleg_creds, gss_host, banner_timeout, auth_timeout, gss_trust_dns, passphrase)
422 username, password, pkey, key_filenames, allow_agent,
423 look_for_keys, gss_auth, gss_kex, gss_deleg_creds, t.gss_host,
--> 424 passphrase,
425 )
426
/Application/DataScience/Anaconda/anaconda3/envs/hub/lib/python3.6/site-packages/paramiko/client.py in _auth(self, username, password, pkey, key_filenames, allow_agent, look_for_keys, gss_auth, gss_kex, gss_deleg_creds, gss_host, passphrase)
713 if saved_exception is not None:
714 raise saved_exception
--> 715 raise SSHException('No authentication methods available')
716
717 def _log(self, level, msg):
SSHException: No authentication methods available
Is this the right way to connect to a server without passphrase or anything is missing
The authentication mechanism is host based one. In the /etc/ssh/ssh_config:
HostbasedAuthentication yes
EnableSSHKeySign yes setting
I believe that is the reason it is not asking for password.