Access VM shared folder via ssh (python parametiko) not working


This Content is from Stack Overflow. Question asked by Flabala

I have some trouble with parametiko…

Context : I am working on windows 10, and I have a virtual machine (ubuntu 20) installed using VMware.
On my windows, I have a folder “ubuntu_shared” that I have shared with my VM.
On my windows cmd line, if I run

ssh <user>@<host>
cd /mnt/hgfs/ubuntu_shared

it works fine.

But if I run with python the same process:

k = paramiko.RSAKey.from_private_key_file(LOCAL_SSH_PRIVATE_KEY)
ssh = paramiko.SSHClient()

num_tries = 0
ssh_connected = False
while not ssh_connected and num_tries < 10:
        ssh.connect(hostname=VM_HOST, username=VM_USER, allow_agent=False, pkey=k)
        ssh_connected = True
        print(f"connected via ssh to {VM_USER}@{VM_HOST}")
    except Exception as e:
        print("still trying...")
        num_tries += 1
if not ssh_connected:
    raise Exception(f"failed to connect : {e}")

command = "cd /mnt/hgfs/ubuntu_shared"
stdin, stdout, stderr = ssh.exec_command(command)
if stderr:

which outputs :

sh: line 0: cd: /mnt/hgfs/ubuntu_shared: Not a directory

What am I doing wrong on python ? doesn’t seem like it’s different is it ?
Thanks in advance 🙂


This question is not yet answered, be the first one who answer using the comment. Later the confirmed answer will be published as the solution.

This Question and Answer are collected from stackoverflow and tested by JTuto community, is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.

people found this article helpful. What about you?