menu Chancel's blog
rss_feed
Chancel's blog
时来天地皆同力

Linux下挂载SMB文件夹(共享文件夹)

作者:Chancel Yang, 时间:2022 Apr 08, 阅读:97

挂载Samba共享文件夹需要安装 cifs-utils ,实测在Ubuntu1804与Manjaro下均可安装

安装 cifs-utils

# Ubuntu1804
sudo apt install cifs-utils

# Manjaro
sudo pacman -S cifs-utils

方法一(明文密码挂载)

明文挂载Samba磁盘命令

sudo mount -t cifs //[ip]/[directory] /mnt/[directory] -o username='xx',password=xx,vers=1.0

方法二(文件凭证挂载)

使用用户凭证挂载Samba磁盘,首先创建 /etc/samba-credentials 用户凭据

cat /etc/samba-credentials

username=user
password=password

修改用户凭据权限

sudo chown root: /etc/samba-credentials
sudo chmod 600 /etc/samba-credentials

挂载命令

sudo mount -t cifs -o credentials=/etc/samba-credentials  //[ip]/[directory] /mnt/[directory]

在开机时进行挂载

sudo crontab -e

@reboot /usr/bin/mount -t cifs -o credentials=/etc/samba-credentials  //[ip]/[directory] /mnt/[directory]

[[replyMessage== null?"发表评论":"发表评论 @ " + replyMessage.m_author]]

account_circle
email
web_asset
textsms

评论列表([[messageResponse.total]])

还没有可以显示的留言...
[[messageItem.m_author]] [[messageItem.m_author]]
[[messageItem.create_time]]
[[getEnviron(messageItem.m_environ)]]
[[subMessage.m_author]] [[subMessage.m_author]] @ [[subMessage.parent_message.m_author]] [[subMessage.parent_message.m_author]]
[[subMessage.create_time]]
[[getEnviron(messageItem.m_environ)]]