【问题标题】:Systemd service ask password系统服务询问密码
【发布时间】:2017-03-09 07:33:50
【问题描述】:

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

mount_cifs@.service

[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!

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

【问题讨论】:

标签: mount systemd cifs


【解决方案1】:

阅读后我发现pwd=$(systemd-ask-password "Password:") 至少是一种方法。现在systemd 不再抱怨了。

【讨论】:

  • 你能分享你完整的.service文件吗?
  • @SilleBille:对不起,我已经没有这个服务文件了。
  • 我知道已经很久了,但是您能分享一下您在服务文件中嵌入的其他信息吗?关注您的帖子后,当我启动服务时,它不会提示用户。我在 Fedora 28 上。
  • @gncs 您是否必须在服务文件中添加 pwd=$(systemd-ask-password "Password:") 行?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-01-04
  • 1970-01-01
  • 1970-01-01
  • 2014-04-07
  • 2020-12-16
  • 2012-05-03
相关资源
最近更新 更多