mount - Systemd 服务询问密码

标签 mount systemd cifs

我正在尝试设置一个 systemd 服务,允许用户挂载 CIFS 共享。这就是我得到的:

<强> [email protected]

[Unit]
Description=Mount CIFS share by %i
After=network-online.target
Wants=network-online.target

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStartPre=/bin/mkdir -p /mnt/dir
ExecStart=/bin/mount -t cifs //remote/path /mnt/dir -o username=%i
ExecStop=/bin/umount /mnt/dir
ExecStopPost=/bin/rmdir /mnt/dir

但是,当我运行 systemctl start <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="8ce1e3f9e2f8d3efe5eaffccebe2efffa2ffe9fefae5efe9" rel="noreferrer noopener nofollow">[email protected]</a> 时,我收到以下消息:

Password for gncs@//remote/path: 
Broadcast message from root@ws (Wed 2016-10-26 21:24:56 CEST):

Password entry required for 'Password for gncs@//remote/path:' (PID 5677).
Please enter password with the systemd-tty-ask-password-agent tool!

我到底应该如何使用这个工具?

最佳答案

经过一番阅读后,我发现 pwd=$(systemd-ask-password "Password:") 至少是一种方法。现在 systemd 不再提示。

关于mount - Systemd 服务询问密码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40270671/

相关文章:

java - android 类未找到错误的致命异常

bash - 如何在 Docker 容器中挂载主机目录

linux - 在 Linux 中使用 mount --bind 挂载文件夹。一个子文件夹出现为空

linux - 删除外部硬盘上的所有分区和分区表

centos7 - 如何在centos中更改systemd超时

python - 如何判断文件是否正在从 Linux 写入 Windows CIFS 共享

linux - 如何挂载从两个源分区组合的 rsync 复制的分区

python - Systemd:启动操作超时。终止

python - Systemd - Python 脚本主进程退出,code=exited,status=1/FAILURE

unix - mount -t nfs 与 cifs