plumbum : SSH to my remote server

856 Views Asked by At

Good day, I am using plumbum on anaconda to connect to my remote server A.

I have create a new user linux2 and assigned a publickey to that user. then changed the permission on the .ssh and authorizedkeys as

chmod 700 /home/linux2/.ssh chmod 600

/home/linux2/.ssh/authorized_keys

When i try the code :

from plumbum import SshMachine
rem=SshMachine("000.000.131.110",user="linux2",Password = "password")

I am getting the below error: Please assist

CommandNotFound Traceback (most recent call last) in () 1 # YOUR CODE HERE 2 from plumbum import SshMachine ----> 3 rem=SshMachine("000.000.131.110",user="linux2",password = "password")

C:\ProgramData\Anaconda3\lib\site-packages\plumbum\machines\ssh_machine.py in init(self, host, user, port, keyfile, ssh_command, scp_command, ssh_opts, scp_opts, password, encoding, connect_timeout, new_session) 77 if ssh_command is None: 78 if password is not None: ---> 79 ssh_command = local["sshpass"]["-p", password, "ssh"] 80 else: 81 ssh_command = local["ssh"]

C:\ProgramData\Anaconda3\lib\site-packages\plumbum\machines\local.py in getitem(self, cmd) 206 else: 207 # search for command --> 208 return LocalCommand(self.which(cmd)) 209 else: 210 raise TypeError("cmd must not be a RemotePath: %r" % (cmd,))

C:\ProgramData\Anaconda3\lib\site-packages\plumbum\machines\local.py in which(cls, progname) 176 if path: 177 return path --> 178 raise CommandNotFound(progname, list(cls.env.path)) 179 180 def path(self, *parts):

CommandNotFound: ('sshpass', [, , , , , , , , , , , , , , , , , , , , , , ])

1

There are 1 best solutions below

0
On

Based on your output, you appear to be running this from a Windows machine. According to the plumbum docs, you should use PuttyMachine (requires putty to be installed), or ParamikoMachine for remote ssh connections on Windows.