Aleksey
Aleksey

Reputation: 41

Why I cant connect to linux computer using netmiko?

from netmiko import (
    ConnectHandler,
    NetmikoTimeoutException,
    NetmikoAuthenticationException,
)

def connect_my_sql(ip_device):
with ConnectHandler(device_type= 'linux', host= '1.1.1.1', username= 'login', password= 'password') as ssh:
              ssh.enable()
              output = ssh.send_command('sqlite3 my.db')
              return output

This is my code, I just want to connect to my computer with Ubuntu, can you help me please

I cant find the problem in my code I know that netmiko has linyx device type, so I think they can connect to the host

Upvotes: 0

Views: 1153

Answers (1)

George Shuklin
George Shuklin

Reputation: 7907

check your sudo settings. ssh.enable() expects to see a sudo password prompt.

If you have 'passwordless sudo' on your server (the usual setup for cloud environments), just use ssh.send_command('sudo sqlite3 my.db'), or, better, try to adjust your permissions to avoid using sudo.

Upvotes: 1

Related Questions