Linux mount cifs without password

Как в Linux монтировать шару CIFS

Что такое Linux и CIFS простыми словами.

Работа с общими папками Windows происходит с использованием протокола CIFS (SMB). Все примеры в данном руководстве выполняются на Linux Ubuntu и CentOS.

Подготовка

Установка пакетов

Для монтирования общей папки необходимо установить набор утилит для работы с CIFS.

yum install cifs-utils

apt-get install cifs-utils

Сетевые порты

Если мы будем монтировать сетевую папку, сервер которой находится за брандмауэром, необходимо открыть следующие порты:

Синтаксис

* вместо mount.cifs можно написать mount -t cifs.

mount.cifs //192.168.1.1/public /mnt

* простой пример монтирования папки public на сервере 192.168.1.1 в локальный каталог /mnt.

Ручное монтирование

Теперь монтирование можно выполнить следующей командой:

mount.cifs //192.168.1.10/share /mnt -o user=dmosk

* в данном примере будет примонтирован каталог share на сервере 192.168.1.10 в локальную папку /mnt под учетной записью dmosk.

То же самое, с использованием домена:

mount.cifs //192.168.1.10/share /mnt -o user=dmosk,domain=dmosk.local

Автоматическое монтирование CIFS через fstab

Для начала создаем файл, в котором будем хранить данные авторизации при подключении к общей папке:

И добавляем в него данные следующего вида:

username=dmosk
password=dPassw0rd
domain=dmosk.local

* в этом примере создана пара логин/пароль — dmosk/dPassw0rd; domain указывать не обязательно, если аутентификация выполняется без него.

Теперь открываем конфигурационный файл fstab:

и добавляем в него следующее:

//192.168.1.10/share /mnt cifs user,rw,credentials=/root/.smbclient 0 0

* в данном примере выполняется монтирование общей папки share на сервере с IP-адресом 192.168.1.10 в каталог /mnt. Параметры для подключения — user: позволяет выполнить монтирование любому пользователю, rw: с правом на чтение и запись, credentials: файл, который мы создали на предыдущем шаге.

Чтобы проверить правильность настроек, вводим следующую команду:

Примеры использования опций

Версии SMB

Если на стороне Windows используется старая или слишком новая версия протокола SMB, при попытке монтирования мы можем получить ошибку mount error(112): Host is down. Чтобы это исправить, указываем версию:

mount.cifs //192.168.1.10/share /mnt/ -o vers=1.0

* монтирование по протоколу SMB1.0

Монтирование от гостевой учетной записи

Если сервер принимает запросы без логина и пароля, то клиент подключается, как гость:

mount.cifs //192.168.1.10/share /mnt -o guest

//192.168.1.10/share /mnt cifs guest 0 0

Права на примонтированные каталоги

При монтировании папки мы можем указать определенные права:

mount.cifs //192.168.1.10/share /mnt -o file_mode=0777,dir_mode=0777

Для указания владельца, который будет назначен для примонтированного каталога, используем:

Читайте также:  Local webserver mac os

mount.cifs //192.168.1.10/share /mnt -o uid=33,gid=33

* чтобы посмотреть идентификаторы пользователя, вводим id -u и id -g .

Источник

Thread: Mounting Windows Share No Password

Thread Tools
Display

Mounting Windows Share No Password

We have a computer here with stuff on it we all use. If I load up my Windows XP VM and open it through My Network Places it loads up just fine. In Ubuntu Nautilus complains that it cant mount the share. If I do:

sudo mount -t cifs //tech1/e /mnt/tech1

it asks for a password. There is no password.

Re: Mounting Windows Share No Password

Are you sure that it’s asking for a share password and not a local password for sudo?

If it really is asking for a share password, try this:

Happy Ubunting!

Re: Mounting Windows Share No Password

Are you sure that it’s asking for a share password and not a local password for sudo?

If it really is asking for a share password, try this:

Yeah, I tried my sudo password and it just said «try again». I tried the -o guest and got «connection refused», I assume the guest account is disabled. The user is Frank so I tried -o Frank and it went back to asking for a password.

Frank claims there’s no password. But maybe Windows just logs him in automatically and there is a password. I think I’ll try logging out on his machine and see if it asks for a password to get back in. Although, Windows doesn’t ask for a password when I connect from a Windows machine.

Also — thinking out loud here — I better try using the IP address instead of the hostname. There may be a DNS problem.

Источник

Include password when mounting a drive using cifs

At first I using this to mount a shared drive:

but then I didn’t have modify access or ownership to the shared drive so this was solved using this question by mounting the shared drive using:

sudo mount.cifs -o username=myuser,uid=youruser,gid=yourgroup //xxx.xxx.xx.xx/myfolder /mnt/windowsshare/ :

it then asks for the password of the network share and then it works.

But when I tried doing this:

sudo mount.cifs -o username=myuser,password=mypassword,uid=youruser,gid=yourgroup //xxx.xxx.xx.xx/myfolder /mnt/windowsshare/

by including the password in the command, it says permission denied, not sure why? Also how I can make this permanent so that I don’t have to rewrite the command every time I lose connection or restart the computer?

1 Answer 1

BEWARE: all options that automate mounting of remote file systems possess some level of risk. See note at the end of this answer.

To make it permanent and automatically connect/reconnect as needed, use the kernel automounter. This will handle connection dropouts, access timeouts, etc.

Читайте также:  Better touch для windows

Install autofs and configure as follows:

The —ghost option keeps the mountpoint folder visable on the file system, which makes things smoother for some programs.

The autofs config string would be something like:

This may need extended for some enviornments. NOTE: The vers=2\.1 option will need to be specified if SMB 1 has been turned off on the remote server.

WARNING! Make that file readable only by root, because the target password is stored in plain text. There are security implications with storing this password in plain text, particularly if you cannot trust root users. These implications must be carefully weighed to assure that there are mitigating controls that adequately address the root level user(s) access risk. One possible option would be to have a separate user created with limited rights to instantiate this connection, and make sure that adequate, auditable logging is enabled so that activities can be traced.

Источник

Automate a mount without linux password to mount a remote cifs filesystem

I have a directory in my Debian home: /home/myuser/pchome/ which i want to use as a mount point for a remote cifs filesystem. So i have a bash script, which is run on every myuser login. This script contains the command:

The command works like a charm using itself in a console. But, the problem is that mount requires sudo and password introduction (or be run with root privileges).

sudoers

First approach i thought about is configure the sudoers to allow the use of mount for myuser. Something like:

The problem with that, is that myuser could use mount without limits, even for mounting filesystems on /etc, for example. I’m not interested in allowing myuser the use of mount command freely.

fstab

Second approach i thought about, is using fstab to allow the mount. I did not test it, but i think that, with this solution, both the mount point and filesystem to mount could be fixed, and no other mount could be done. But, every user could perform the mount (if using the «user» option for fstab line).

From my point of view, none of the two ideas is correct enought, so i would like if any of you knows the valid approach to that problem. I only want to be allowed to mount a public remote filesystem using a mount point inside my home without any concern about security, passwords or exposing the system to malicious mounts. It should be easier, since the mount point is inside my own home.

Источник

How do I mount a CIFS share?

I’m using Ubuntu 11.10, and am trying to mount a freenas server. I have the server set to share in cifs and nfs with no luck.

Читайте также:  Mumu mac os �������� ����

I have tried smbmount //192.168.1.### /mnt/

I am not new to Ubuntu but am nowhere near a power user, so I’d prefer a GUI option if available.

How do I mount a cifs share in 11.10?

8 Answers 8

There is pyNeighborhood which is a gui for mounting samba shares and available in the software centre for download.

There is a good article located here on how to set it up and use it.

First install cifs utils

Alternatively, the basic terminal command is :

If you’d like to see your mount in Nautilus it would be good to create a subfolder first in /media/USERNAME/ for example:

also, password could ommited in the mount command for example (will also demonstrate file/folder modes):

in this case you’ll be asked for the password (actually for 2 passwords) on the mounting moment.

Have a read through the Samba documentation here on how to do it and set it up correctly to mount on start up etc.

It’s as map7 said, but if you don’t want to use root permissions every time you change a file on the drive, then you’ll have to mount to a user folder, and make sure the gid and uid are set to your username.

The command setting them:

Note that mnt folder was created in

/mnt/share instead of /mnt/share .

Also you can leave out password=PASSWD if you want it to prompt you instead of you having it in the command, which is potentially stored in your shell’s history:

1) My samba share shows in Caja (the ubuntu 16.04 „explorer“) as

This is a good lithmus test, there are no connection/path issues.

(caveat: If you get asked by caja about password credentials from your windows machine, you might want to switch Domain from WORKGROUP to the name of the machine, i.e. ‘thinkpad’. Then the truly local login credentials of your drive should do.)

2) If that works, here comes the command:

  • Make sure beforehand, /mnt/ddrive exists as an empty directory.
  • You cold also add a ,password=supersecret directly (no space) after username=, but you can also wait for being prompted, when you enter the command.

I disagree with the claim that root is always necessary to make cifs connections go. It is true, it is always needed for CLI smbmount, but a file manager such as nautilus has ability to mount a cifs share and it is not necessary to be root.

I don’t use Gnome, but I still have Nautilus installed. Run this in a terminal to prevent having it try to take over the desktop

Источник

Оцените статью