Sample Header Ad - 728x90

Can a shell opened via SSH "inherit"/use the same environment as a local shell? Non-interactive shell on MacOS can, "sometimes", not access Keychain

1 vote
0 answers
44 views
I use Pushbullet and a third party Python script that allows me to send "pushes" from the command line. This script uses MacOS "Keychain" to access passwords and tokens used for Pushbullet. If I execute the script locally, something like % pb push "SE demo" in works fine and the "push" is sent as expected, but I need to send it using ssh from machine A to B: % ssh B pb push "SE\ demo" but when I do I get a traceback that the script can't access *Keychain*. I can work around that by first unlocking the Keychain: % security -i unlock-keychain but you have to do that everytime you want to send a push, which kind of defeats the purpose of the Keychain. The key difference between a local shell and ssh is that ssh shells are **non-interactive** (if I open a local shell and su I get a **non-login** but interactive shell - in such a shell it still works to send these pushes/there are no issues with Keychain). **How can I, using ssh, access the environment of a local interactive shell so my script can access the Keychain?** Additional details. What I am actually doing is running an AppleScript via SSH: % ssh B osascript ~/scripts/myscript At the end of this AppleScript I execute a shell script that sends this Pushbullet push do shell script "pb push 'done'" and it is this command that fails because it can't access the Keychain. If I execute the AppleScript locally on B, from the Script Editor or the command line, the do shell script-part works. OTOH, AppleScript reports that the environment it executes its do shell-script is non-interactive and non-login.
Asked by d-b (2047 rep)
Apr 28, 2024, 04:55 PM
Last activity: Apr 29, 2024, 05:44 AM