I am writing some automation API in C working with remote file system via SSH.

The host is running Ubuntu-Linux and one of the target machine is running Windows 7 with OpenSSH installed.

The specific function I am having trouble with is to list the files in the remote Windows system. In particular, those files and folders with space in their names. For example: "Foo BAR"

The format of my command looked like this

sshpass -p [pwd] ssh [account]@[ip_addr] dir PATH

If I do:

sshpass -p [pwd] ssh -v [account]@[ip_addr] dir C:\"FOO BAR"

With verbose(-v) option, it gives me the following response(snippet):

debug1: Sending command: dir C:"Foo BAR
  Volume in drive C has no label.
File Not Found

If I do:

sshpass -p [pwd] ssh -v [account]@[ip_addr] dir C:\\\"FOO BAR\"

It returns:

debug1: Sending command: dir C:\\"FOO BAR"
  Volume in drive C has no labe.
File Not Found

When I run it through automation, it will return:

sh: 1: Syntax error: Unterminated quoted string

My API works perfect for those filenames with no spaces in between. Seems like a limitation sending commands as such to windows system. Any ideas how to resolve this?


Update 11/14:

Thanks for the reply warl0ck! I wasn't aware of this SSHFS, gonna give it a try first.

Following the link you provided, during this step:

sudo sshfs -o allow_other,defer_permissions [email protected]:/ /mnt/droplet

I got the following error:

fuse: unknown option `defer_permissions`

After asking google, I changed it to:

sudo sshfs -o allow_other,default_permissions [email protected]:/ /mnt/droplet

Then I ran into the following error:

read: Connection reset by peer

I followed through this Connection reset by peer using sshfs and did:

sudo usermod -a -G fuse [my_user_name]

But I still got the same issues, any ideas?

1 Answer 1


To avoid quoting issue, you can pass arguments in base64 and decode them on the linux server.

But why creating your own api where there's SSHFS? see the following link for help


  • I am sending the commands through SSH on Linux, so you mean encode the strings via base64, send it over SSH to remote windows and decode the string from there?
    – ObigOne
    Nov 15, 2016 at 2:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .