0 votos

Python no puede acceder a Keychain cuando se ejecuta a través de SSH, ¿pero funciona desde una terminal local?

Utilizo Pushbullet CLI para enviar notificaciones Pushbullet desde la terminal. Funciona bien cuando lo ejecuto localmente, pero cuando hago SSH en la máquina donde está instalado e intento enviar una notificación, obtengo un seguimiento de Python:

% pb push test
Traceback (most recent call last):
  File "/Users/db/Library/Python/3.11/lib/python/site-packages/keyring/backends/macOS/__init__.py", line 51, in get_password
    return api.find_generic_password(self.keychain, service, username)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/db/Library/Python/3.11/lib/python/site-packages/keyring/backends/macOS/api.py", line 144, in find_generic_password
    Error.raise_for_status(status)
  File "/Users/db/Library/Python/3.11/lib/python/site-packages/keyring/backends/macOS/api.py", line 114, in raise_for_status
    raise cls(status, "Unknown Error")
keyring.backends.macOS.api.Error: (-25308, 'Unknown Error')

Durante el manejo de la excepción anterior, ocurrió otra excepción:

Traceback (most recent call last):
  File "/Users/db/Library/Python/3.11/bin/pb", line 8, in 
    sys.exit(main())
             ^^^^^^
  File "/Users/db/Library/Python/3.11/lib/python/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/db/Library/Python/3.11/lib/python/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/Users/db/Library/Python/3.11/lib/python/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/db/Library/Python/3.11/lib/python/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/db/Library/Python/3.11/lib/python/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/db/Library/Python/3.11/lib/python/site-packages/pushbullet_cli/app.py", line 239, in push
    _push(**kwargs)
  File "/Users/db/Library/Python/3.11/lib/python/site-packages/pushbullet_cli/app.py", line 63, in _push
    pb = _get_pb()
         ^^^^^^^^^
  File "/Users/db/Library/Python/3.11/lib/python/site-packages/pushbullet_cli/app.py", line 47, in _get_pb
    password = keyring.get_password("pushbullet", "cli")
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/db/Library/Python/3.11/lib/python/site-packages/keyring/core.py", line 55, in get_password
    return get_keyring().get_password(service_name, username)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/db/Library/Python/3.11/lib/python/site-packages/keyring/backends/chainer.py", line 51, in get_password
    password = keyring.get_password(service, username)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/db/Library/Python/3.11/lib/python/site-packages/keyring/backends/macOS/__init__.py", line 57, in get_password
    raise KeyringError("Can't get password from keychain: " "{}".format(e))
keyring.errors.KeyringError: Can't get password from keychain: (-25308, 'Unknown Error')

Supongo que el problema es que la shell que obtengo al hacer SSH es diferente de una shell local, pero ¿cómo lo arreglo?

1voto

Linc D. Puntos 11

Asegúrate de que la clave esté en el llavero local predeterminado (generalmente llamado 'login'). Desbloquea el llavero a través de SSH ingresando el siguiente comando

security -i unlock-keychain

para obtener un aviso de contraseña.

AppleAyuda.com

AppleAyuda es una comunidad de usuarios de los productos de Apple en la que puedes resolver tus problemas y dudas.
Puedes consultar las preguntas de otros usuarios, hacer tus propias preguntas o resolver las de los demás.

Powered by:

X