VPN이 systemd-ask-password 프롬프트를 표시하지 않습니다.

VPN이 systemd-ask-password 프롬프트를 표시하지 않습니다.

비밀번호로 보호된 개인 키를 사용하는 작동 중인 OpenVPN 클라이언트 구성이 있습니다.

직접 실행 하면 openvpn비밀번호를 묻는 메시지가 표시되고 클라이언트가 성공적으로 시작됩니다.

하지만 내가 시작하면 systemctl나는아니요암호를 묻는 메시지가 표시되고 서비스 초기화가 완료되지 않습니다.

systemd-ask-password비밀번호를 기다리는 것 같지만 프롬프트가 표시되지 않습니다.

$ sudo systemctl start openvpn-myclient.service
$ systemctl status openvpn-myclient.service
● openvpn-myclient.service - OpenVPN instance ‘myclient’
   ...
   Status: "Pre-connection initialization successful"
    ...
   CGroup: /system.slice/openvpn-myclient.service
           ├─18997 openvpn --suppress-timestamps --config /path/to/client.conf
           └─18998 /path/to/systemd-ask-password --icon network-vpn Enter Private Key Password:

비밀번호를 제출하라는 메시지를 수동으로 만들 수 있습니다.

$ sudo systemd-tty-ask-password-agent --query
Enter Private Key Password: ************************

askpass /path/to/passphraseclient.conf를 넣어서 문제를 해결할 수도 있었습니다. 이렇게 하면 사용자 입력이 필요하지 않지만 비밀번호를 일반 텍스트로 저장해야 합니다.

무슨 일이 일어나고 있는지, 프롬프트를 표시하기 위해 무엇을 할 수 있는지, 비밀번호를 일반 텍스트로 입력하지 않는 방법을 알고 싶습니다.

어떻게 더 디버깅할 수 있나요? 다음 매뉴얼 페이지를 읽었지만 여전히 그 내용을 이해하지 못합니다.

  • systemd-ask-password
  • systemd-tty-ask-password-agent
  • systemd-ask-password-wall.service

답변1

실험 후 systemctl은 Type=simple.

Type=notify서비스 자체에서 sd_notify를 사용하여 데몬이 시작되었음을 systemd에 알리면 작동합니다 .sd_notify(3)

그런 다음 프로세스가 실행 중이면 systemd-ask-password프롬프트에 나타나야 합니다.

user@machine:~$ sudo systemctl start daemon-example
daemon-example *************

순수 쉘 PoC 예:

#!/bin/sh

export PW=$(systemd-ask-password "example:")

systemd-notify --ready  # only if the service itself does not call `sd_notify`

echo "$PW" # for PoC

# dummy service, replace by `exec /usr/bin/my-service` otherwise
while true; do
    sleep 10
done
# /etc/systemd/system/password-example.service
[Unit]
Description=example

[Service]
Type=notify
ExecStart=/tmp/example.sh
user@machine:~$ sudo systemctl start password-example.service

답변2

매개변수 없이 "askpass"를 사용하면 작동합니다.

관련 정보