22 lines
807 B
Python
Executable File
22 lines
807 B
Python
Executable File
#!/usr/bin/env python3
|
|
"""Only OpenSSH may consume this helper's output; never run it interactively."""
|
|
import os
|
|
import re
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
if __name__ == '__main__':
|
|
prompt = sys.argv[1] if len(sys.argv) == 2 else ''
|
|
match = re.fullmatch(r"root@(104\.168\.30\.40|45\.153\.247\.44)'s password: ?", prompt)
|
|
if not match or os.environ.get('SSH_ASKPASS_REQUIRE') != 'force':
|
|
raise SystemExit(2)
|
|
root = Path('/Users/hellcat/Documents/GemDocs/AI版')
|
|
sys.path.insert(0, str(root / 'tools'))
|
|
import credentials
|
|
resource = {'104.168.30.40': 'VPS-001', '45.153.247.44': 'VPS-003'}[match[1]]
|
|
try:
|
|
password = credentials.get_field(root, resource, 'password')
|
|
os.write(1, password.encode())
|
|
except Exception:
|
|
raise SystemExit(2)
|