Sublime Forum

Set environment variable

#1

Is it possible to tell Sublime Merge to use specific environment variables?
Like SSH_AUTH_SOCK. I’m using a yubikey to store my ssh key, and is therefore using the gpg-agent as the ssh agent

0 Likes

#2

What platform are you on?

0 Likes

#4

@wbond

I’m on MacOS, using zsh and oh-my-zsh.
Also using build 1114 of Sublime Merge.

0 Likes

#5

If I remember correctly this worked for me - https://evilmartians.com/chronicles/stick-with-security-yubikey-ssh-gnupg-macos

0 Likes

#6

I’ll give that a try. Perhaps it’s the LaunchAgent thingy I need to add. Though, it would be nice if SublimeMerge soon would allow for extensions, as for ST3 I just changed os.environ['SSH_AUTH_SOCK']

0 Likes

#7

@ChainsawBaby

Should work if you put export SSH_AUTH_SOCKET=$HOME/.gnupg/S.gpg-agent.ssh in your ~/.profile.

Your ~/.profile is loaded as soon as you login on MacOS and should set the env variable system-wide for all applications. (Restart required) Just be sure to completely disable the default ssh-agent in MacOS, otherwise it can take control of the socket again.

I’ve made the mistake of ‘starting’ Sublime Merge with a specific env variable. Works great, until you start using Sublime Merge by clicking the branch name in Sublime Text.

You should at least be able to test if it’s working by running SSH_AUTH_SOCK=/path/to/sock.ssh open /path/to/sublime.app from your terminal.

0 Likes

#8

I’m pretty sure I did that, but not restart (I find those things tedious)
I’ll give it a try later on

0 Likes

#9

I have the same problem but I’m on Debian Linux.

I can’t git push with SublimeMerge because it probably doesn’t recognize my PGP key which is stored on the smart card of a Nitrokey and used for SSH auth aswell.

This is what I get:

git@gitea.xxx.local: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure that you have the correct access permissions and that the repository exists.

On CLI it works fine.

I have no idea what to do now. I’m thankful for any advice.

0 Likes

#10

I’m on Arch and adding the following to .profile made Sublime Merge able to pick it up properly:

export SSH_AUTH_SOCK=$(gpgconf --list-dirs agent-ssh-socket)

However, before doing that, I was not able to get it work by testing it with:

SSH_AUTH_SOCK=$(gpgconf --list-dirs agent-ssh-socket) smerge .

Which I find weird. Just wanted to chime in as nobody seems to have confirmed your suggestion as working.

(Sorry if this counts as necro and is not allowed, I checked the FAQ but didn’t find anything concerning such policies.)

0 Likes