After updating system to latest samba-client package in Red Hat Enterprise Linux, mount.cifs returns Error 13 when used with credential file option.

Solution Verified - Updated -

Environment

  • Red Hat Enterprise Linux 4.8 with samba-client 3.0.33-0.18.el4_8.
  • Red Hat Enterprise Linux 5.4 with samba-client-3.0.33-3.15.el5_4.
  • Correct password in credential file, with trailing newline after password.

Issue

  • After updating system to the latest Samba package samba-client 3.0.33-0.18.el4_8 (in RHEL 4 ) and samba-client-3.0.33-3.15.el5_4 ( in RHEL 5) the mount.cifs command with credential file option throw following error :
# mount -v -t cifs  //server/sharename /mnt/ -o credentials=/etc/credentials
mount error 13 = Permission denied
Refer to the mount.cifs(8) manual page (e.g.man mount.cifs
  • Same command will work if credentials file option is not used for example :
mount -v -t cifs  //server/sharename /mnt/ -o username=testuser,password=testpassword

Resolution

Root Cause

Diagnostic Steps

  • Attempt to mount using credentials file with trailing newline:
# cat /etc/credentials 
username=username
password=password
# mount -v -t cifs  //server/sharename /mnt/ -o credentials=/etc/credentials
mount error 13 = Permission denied
Refer to the mount.cifs(8) manual page (e.g.man mount.cifs
  • Workaround is to remove trailing newline after password:

  • Create Credential file as follows and mount command will work :

# cat /etc/credentials 
username=username
password=password#
  • Or create a credential file without newline character at the end of the line:
# printf "username=user1\npassword=secret" > /cred_file  (this will create a file without a new line character after password)
# mount.cifs //server1.example.com/test /mnt -o credentials=/cred_file
  • Another workaround is to add the "null" character at end of lines. The following should work with both smbclient and mount.cifs
printf "username=user1\0\ndomain=test.com\0\npassword=secret\0\n" > /cred_file
# mount.cifs //server1.example.com/test /mnt -o credentials=/cred_file

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Comments