Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Right now I'm connecting to network shares on my windows 7 machine with a command like sudo mount -o username=Robert // /mnt/share and then it asks for my password. No big deal, but I'd rather have it just connect properly when I do sudo mount // /mnt/share.

I know there's a config file to do this somewhere, I'm just not sure what/where it is and how it should be set up. I'd rather not do -o username=Robert,password=hunter123.

Samba is whatever is the latest and greatest from debain testing.

share|improve this question
up vote 2 down vote accepted

You can do this by setting your username and password in /etc/fstab. Of course, there are some security implications in doing so, as all users on your system will be able to see the password.

E.g. add a line like::

// /mnt/share cifs username=robert,password=hunter123 0 0

See also man mount.cifs, which documents some of the alternative ways in which you could pass credentials.

share|improve this answer
credentials file sounds good, it's a bit better anyway. I'll try a few things out. – Rob Jan 16 '12 at 16:21
Ended up just making a new alias mountc='sudo mount -o credentials=/home/robert/.smbcred' and that worked fine. Could've made it an alias with username=USER,password=PASSWORD, but I can chmod my credentials file since it's read by root. – Rob Jan 16 '12 at 16:31

you could also set up the smb.conf file (/etc/samba/smb.conf) to add the share sans-authentication.

# /etc/samba/smb.conf file for COMPLETELY INSECURE SHARING
# You need to replace each "USER_NAME" instance with your username
# Apps... Accessories... gedit Text Editor. Search... Replace

workgroup = WORKGROUP
server string = [HOSTNAME OF YOUR SERVER]
security = share
name resolve order = hosts lmhosts

path = /path/to/share
force user = [username on server]
force group = [group on server]
read only = no
guest ok = yes

restart samba with

sudo /etc/init.d/smbd restart
sudo /etc/init.d/nmbd restart

and the share should show uo as normal, and will not require authentication.

note everyone on the network will be able to see and access this share.

share|improve this answer
The share is open to read only for everyone, I need to log in to do file moves and deletions, so that's not an issue. I'd still need to authenticate with the windows machine with this. – Rob Jan 16 '12 at 16:20

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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