Answers:
有pyNeighborhood,它是安装samba共享的gui,可以在软件中心下载。
这里有一篇很好的文章,介绍如何设置和使用它。
首先安装cifs utils
sudo apt-get install cifs-utils
另外,基本的终端命令是:
mount -t cifs -o username=USERNAME,password=PASSWD //192.168.1.88/shares /mnt/share
如果您想在Nautilus中看到挂载,最好先在/ media / USERNAME /中创建一个子文件夹,例如:
mkdir /media/paul/cifsShare
同样,例如在mount命令中可以省略密码(还将演示文件/文件夹模式):
sudo mount -t cifs //nas-server/cifsShare /media/paul/cifsShare -o username=paulOnNAS,iocharset=utf8,file_mode=0777,dir_mode=0777,soft,user,noperm
在这种情况下,安装时会要求您输入密码(实际上是2个密码)。
仔细阅读Samba文档,了解如何进行操作并正确设置以在启动时安装等。
cifs-utils
是促使我前进的动力。否则,这些都将无效。这应该直接包含在答案中。
就像map7所说的那样,但是如果您不想每次更改驱动器上的文件时都使用root权限,则必须挂载到用户文件夹,并确保将gid和uid设置为您的用户名。
设置它们的命令:
mount -t cifs -o username=USERNAME,password=PASSWD,uid=$USER,gid=$USER //192.168.1.88/shares ~/mnt/share
请注意,mnt
文件夹创建于~/mnt/share
而不是中/mnt/share
。
另外,如果您想让密码提示您而不是在命令中输入密码,也可以省略password = PASSWD,该密码可能存储在外壳程序的历史记录中:
mount -t cifs -o username=USERNAME,uid=$USER,gid=$USER //192.168.1.88/shares ~/mnt/share
1)我的桑巴分享在Caja(Ubuntu 16.04“ explorer”)中显示为
smb://thinkpad/ddrive/
这是一个很好的石蕊测试,没有连接/路径问题。
(警告:如果caja询问您Windows计算机上的密码凭据,您可能希望将Domain从WORKGROUP切换到该计算机的名称,即“ thinkpad”。然后,应该使用驱动器的真正本地登录凭据。)
2)如果可行,则命令如下:
sudo mount -t cifs -o username=frank //thinkpad/ddrive /mnt/ddrive
,password=supersecret
在username =之后直接添加一个空格(无空格),但是当您输入命令时,也可以等待提示。我不同意建立CIF连接始终必须使用root的说法。的确,CLI smbmount始终需要它,但是像nautilus这样的文件管理器具有安装cifs共享的能力,并且不必是root用户。
我不使用Gnome,但仍然安装了Nautilus。在终端中运行此程序以防止其尝试接管桌面
$ nautilus --no-desktop &
在Ubuntu 16.04中,左侧树菜单的底部具有“连接到服务器”。单击该按钮,建议输入“ smb://foo.example.com”。smb是“ cifs”的旧词,如果您放入服务器并在开始时与smb://共享,则连接确实有效!我承诺。如果您的共享是一个命名的东西,则必须在斜杠“ smb://foo.example.com/myshare”之后加上。
我以相同的方式使用了其他文件管理器。协议必须为“ smb://”。
您可以将所有这些详细信息放在/ etc / fstab中,以便在系统启动时挂载目录。如果Windows或SMB服务器位于IP地址192.168.1.1上
/etc/fstab
//192.168.1.1/SharedFolder/ /mnt/linux_smb cifs username=winuser,password=TopSecret 0 0
创建目录作为linux挂载点
mkdir /mnt/linux_smb
chmod 755 /mnt/linux_smb
首次手动安装
mount -a
最终错误可以通过以下方式找到
dmesg | tail
当CIF / SMB版本在Linux和Windows之间不兼容时,可能存在特定的问题,并且很难解决。在这种情况下,您可以在fstab行中进行小改动,添加“ vers = 2.1”
因此,如果Windows或SMB服务器位于IP地址192.168.1.1上
/etc/fstab
//192.168.1.1/SharedFolder/ /mnt/linux_smb cifs vers=2.1,username=winuser,password=TopSecret 0 0
步骤2、3和4与前面的答案相同。
我整理了一个小脚本(虽然它是用于Fedora的),以便从命令行挂载CIFS文件系统并创建/删除测试文件。可能有一些用处:
#!/bin/bash
# Passes https://www.shellcheck.net/
set -o nounset
# See
# https://wiki.samba.org/index.php/Mounting_samba_shares_from_a_unix_client
# https://access.redhat.com/solutions/448263
# and also
# https://serverfault.com/questions/309429/mount-cifs-credentials-file-has-special-character
# One needs to run "yum install cifs-utils" to have the kernel module, man page
# and other stuff.
rpm --query cifs-utils > /dev/null
if [[ $? != 0 ]]; then
echo "Package cifs-utils is not installed -- exiting" >&2
exit 1
else
ver=$(rpm --query cifs-utils)
echo "Package $ver exists ... good!" >&2
fi
# Where to find credentials? Use the "credential file" approach, which
# we call "authfile". Example content (w/o the leading #) below.
# Make sure there are no spaces around '=' (this is different than
# for "smbclient" which can deal with spaces around '='.)
# ----8<------8<----------------
# username=prisoner
# password=KAR120C
# domain=VILLAGE
# ----8<------8<----------------
# Trailing empty lines will lead to (harmless) error messages
# "Credential formatted incorrectly: (null)"
authfile='/etc/smb.passwd' # Make sure read permissions are restricted!!
# Server to contact.
# In the UNC path, we will use DNS name instead of the (more correct?)
# NetBIOS name.
# mount.cifs manpage says: "To mount using the cifs client, a tcp name
# (rather than netbios name) must be specified for the server."
server_dns=thedome.example.com
# The name of the connecting client, just to be sure (probably useless)
client_nbs=$(hostname --short | tr '[:lower:]' '[:upper]')
if [[ -z $client_nbs ]]; then
client_nbs=UNKNOWN
fi
# Connect to a certain service (which is a fileservice)
# and then switch to the given directory.
# Instead of appending $directory to form the complete UNC
# (Uniform Naming Convention) path, one could also use the option
# "prefixpath".
# If there is no need to mount a subdirectory of the service,
# the UNC would just be unc="//$server_dns/$service_name"
service_name='information'
directory='PERSONALDATA'
unc="//$server_dns/$service_name/$directory"
# Finally, we will mount the CIFS filesystem here (the
# permissions on that node are not directly of interest)
mntpoint=/mnt/portal
if [[ ! -d "$mntpoint" ]]; then
mkdir "$mntpoint"
if [[ $? != 0 ]]; then
echo "Could not create mountpoint '$mntpoint' -- exiting" >&2
exit 1
fi
fi
# Only this user will be able to access the mounted CIFS filesystem
user=number6
group=number6
# Try to mount this so that only user "number6" can access it
mount -t cifs \
"$unc" \
"$mntpoint" \
--read-write \
--verbose \
-o "credentials=$authfile,uid=$user,gid=$group,netbiosname=$client_nbs,file_mode=0660,dir_mode=0770"
res=$?
if [[ $res != 0 ]]; then
echo "Mount failed!" >&2
echo "Return code $res; more info may be in kernel log or daemon log" >&2
echo "Try 'journalctl SYSLOG_FACILITY=0' or 'journalctl SYSLOG_FACILITY=3'" >&2
echo "...exiting" >&2
exit 1
fi
# Check permissions on the mount point
stat=$(stat --format="group=%G user=%U access=%A" "$mntpoint")
soll="group=$group user=$user access=drwxrwx---"
if [[ $stat != "$soll" ]]; then
echo "Incorrect permissions on root of '$mntpoint'" >&2
echo "Expected: $soll" >&2
echo "Obtained: $stat" >&2
echo "...exiting" >&2
umount "$mntpoint"
exit 1
fi
# CD to the mountpoint to be sure
cd "$mntpoint"
if [[ $? != 0 ]]; then
echo "Could not cd to '$mntpoint'" >&2
exit 1
fi
# CD to directory TEST which must exist (change as appropriate)
newcd="$mntpoint/TEST"
if [[ ! -d "$newcd" ]]; then
echo "Directory '$newcd' not found - can't test!" >&2
echo "...exiting" >&2
exit 1
fi
cd "$newcd"
if [[ $? != 0 ]]; then
echo "Could not cd to '$newcd'" >&2
exit 1
fi
# Create a file and check the permissions
testfile=$(mktemp --tmpdir="$newcd")
if [[ $? != 0 ]]; then
echo "Could not create temporary file in '$newcd'" >&2
exit 1
fi
stat=$(stat --format="group=%G user=%U access=%A" "$testfile")
soll="group=$group user=$user access=-rw-rw----"
if [[ $stat != "$soll" ]]; then
echo "Incorrect permissions on temporary file '$testfile'" >&2
echo "Expected: $soll" >&2
echo "Obtained: $stat" >&2
echo "...exiting" >&2
exit 1
fi
/bin/rm "$testfile"
echo "Mounted '$unc' on '$mntpoint'" >&2
各种安装方法的工作方式已用尽,但您可能需要考虑一些事项
如果您不想直接将凭据输入到/ etc / fstab中,则可以使用安装选项:凭据= /您的路径/此处/.credentials
这应该包含用户名= msusername密码= mspassword
保存文件并退出您的选择编辑器。
权限应更改为chmod 600
如果您具有加密的主目录,并且希望在启动时挂载,请确保将文件放在主目录之外。在/ etc /或/ media /中可能是一个合适且容易记忆的地方。