我正在尝试设置一个 systemd 服务,允许用户挂载 CIFS 共享。这就是我得到的:
[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/