系统服务问密码

时间:2016-10-26 19:29:02

标签: mount systemd cifs

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

mount_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 mount_cifs@gncs.service时,我收到以下消息:

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!

我应该如何使用此工具?

1 个答案:

答案 0 :(得分:0)

经过一番阅读后,我发现pwd=$(systemd-ask-password "Password:")至少有一种方法可以做到这一点。现在systemd不再抱怨了。

相关问题