Skip to content

Unable to view shares or send files to AWS FSx #97

@Sparkz0629

Description

@Sparkz0629

We use go-smb2 to do file deliveries to a host of different windows shares.

We recently had a requirement to do deliveries to FSx using the supported smb protocol.

This is authenticated using our local domain.

I am able to initiate a connection to the target server, however if i try and list the shares, i only see the "IPC$" share.
None of the other shares are visible/accessible.

To confirm it was not a auth issue, i connected to the share from command line using smbclient, and that works 100%.

The error we get is {Network Name Not Found} The specified share name cannot be found on the remote server.

See below code:

user := target.User
pass, err := target.Password.GetPassword()
if err != nil {
	fmt.Println("Unable to load password: ", err.Error())
	return err
}
host := target.Host
port := target.Port
addr := fmt.Sprintf("%s:%d", host, port)

conn, err := net.Dial("tcp", addr)
if err != nil {
	fmt.Fprintf(os.Stderr, "Failed to connect to [%s]: %v\n", addr, err)
	return err
}
defer conn.Close()

d := &smb2.Dialer{
	Initiator: &smb2.NTLMInitiator{
		User:     user,
		Password: pass,
		Domain:   target.Domain,
	},
}

s, err := d.Dial(conn)
if err != nil {
	fmt.Fprintf(os.Stderr, "Unable connect to server: %v\n", err)
	return err
}
defer s.Logoff()

names, err := s.ListSharenames()
if err != nil {
	panic(err)
}

fmt.Println("Available shares:")
for _, name := range names {
	fmt.Println(name)
}

fmt.Fprintf(os.Stdout, "Mounting share [%s] ...\n", target.Share)
fs, err := s.Mount(target.Share)
if err != nil {
	fmt.Fprintf(os.Stderr, "Unable to mount share: %v\n", err)
	return err
}
defer fs.Umount()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions