Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Sparkz0629 opened this issue Jan 27, 2025 · 0 comments
Open

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

Sparkz0629 opened this issue Jan 27, 2025 · 0 comments

Comments

@Sparkz0629
Copy link

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()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant