1

I'm using this command for testing the SMB connection:

smbclient -A=credential_file -L \\hostname  


    Sharename       Type      Comment
    ---------       ----      -------
    ADMIN$          Disk      Remote Admin
    C$              Disk      Default share
    Acme            Disk
    Acme Directory  Disk
    Share           Disk
SMB1 disabled -- no workgroup available

I can explore the Acme directory because there isn't space in its name with this command :

smbclient -A=credential_file \\\\hostname\\Acme -c "dir"

but if I want to explore the directory Acme Directory with these command as example I've error message

smbclient -A=credential_file \\\\hostname\\Acme\ Directory -c "dir"
NT_STATUS_ACCESS_DENIED listing \*

smbclient -A=credential_file \\\\hostname\\Acme\%20Directory -c "dir"
tree connect failed: NT_STATUS_BAD_NETWORK_NAME

How to explore directory with space in its name ?

3
  • 1
    I know little about Samba. Are you sure NT_STATUS_ACCESS_DENIED means there is a problem with the name? In the last case there was a problem with the name and you got NT_STATUS_BAD_NETWORK_NAME. Commented Apr 25, 2023 at 12:17
  • Perhaps the apparent space is some other character, like non-breaking space? Try passing the -L output through cat -t. Note, you can use "/" instead of backslash in the cli, and then don't need to escape, eg: smbclient //hostname/Acme. Commented Apr 26, 2023 at 13:45
  • You can use slash in the fstab file configuration for mounting the cifs but not with smbclient. In the fstab file, I use the ascii code \040 in place of the space like //hostanme/directory1\040Super\040Directory. I mean the backslash is used for mark a special character and in this case it's backslash. It's the reason there are 4 backslash before the hostname. Commented Apr 27, 2023 at 14:53

2 Answers 2

1

I don't see a problem accessing a share name that contains spaces:

Server smb.conf

[Spaced out]
    comment = Testing a space in the share name
    path = /home/remote/tmp
    force user = remote
    force group = remote
    force create mode = 0664
    force directory mode = 0775
    guest ok = no

Client

smbclient -U "$user%$password" '//SAMBASERVER/Spaced out'
smb: \> dir
  .                                   D        0  Thu Jan 25 17:43:42 2024
  ..                                  D        0  Tue Oct 15 12:07:22 2019
  …other stuff…
                1030995672 blocks of size 1024. 56076844 blocks available
smb: \>

Differences between my version and yours:

  • Quoted pathnames, to protect them from the shell
  • Forward slashes instead of pairs of backslashes
  • smbclient --version reports Version 4.17.12-Debian
0

The below command will work to connect with the "Acme Directory"

smbclient \\\\hostname\\Acme\ Directory -U "resourced.local\V.Ventz"

here is the example to conclude :

enter image description here

1
  • Please don't post pictures of text Commented Jun 14, 2024 at 22:13

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.