10

I am connecting to a samba share using the following command..

/usr/bin/smbclient \\\\server78\\publicfolder

It asks me for my linux account password before it will connect.

This isn't a problem if I am running it manually but how can I use this within a bash script without it asking me for the password?

1 Answer 1

9

It should be possible to do it.
From man smbclient :

  -U|--user=username[%password]
       Sets the SMB username or username and password.
       If %password is not specified, the user will be prompted.

So you could use something like :

/usr/bin/smbclient \\\\server78\\publicfolder -U=user%password
4
  • But surely this is for setting the username and password for the samba share? May 27, 2016 at 15:32
  • 2
    it is for providing the user and password for the samba share in order to access it
    – magor
    May 27, 2016 at 15:33
  • 1
    That is not what the original question asks, it asks for the current linux user account password, not the samba share password May 27, 2016 at 15:34
  • 4
    @fightstarr20 the username and password specified by the -U flag is the username and password required to access the share. Whether those credentials are Samba specific or your usual Linux credentials depends how the share has been defined on the server. If this is insufficient you'll need to update your question to include the [global] and [share]-specific sections of your smb.conf May 27, 2016 at 15:40

You must log in to answer this question.

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