4

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?

4

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
  • But surely this is for setting the username and password for the samba share? – fightstarr20 May 27 '16 at 15:32
  • 2
    it is for providing the user and password for the samba share in order to access it – mazs May 27 '16 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 – fightstarr20 May 27 '16 at 15:34
  • 3
    @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 – roaima May 27 '16 at 15:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.