![]() # Remove SSH_AUTH_SOCK to disable tmux automatically resetting the variable set -g update-environment "DISPLAY SSH_ASKPASS SSH_AGENT_PID \ SSH allows you to create a file on the remote server with commands to run when you connect. It allows multiple SSH connections per user to have different ssh-agent settings for one. There are legitimate reasons to set the socket via temp files. I was hoping to make this a little more automatic. Unfortunately, that also means that every time you connect to tmux, you’ll have to run this. Props to Josh Greenwood for not only solving this problem but also fitting the fix into a tweet □. One way is to create a bash function that can query tmux and get the current value of these I just ended up with this function for tmux + agent issues: For that, we have two possible solutions. That leaves old windows and panes, though. In fact, if you create a new window or pane on an old SSH session, it will give the current SSH_AUTH_SOCK variable for you. There’s a list of environment variables that are automatically updated every time you create or join a new tmux session. Now, tmux also lets you store and retrieve environment variables. This is why you can’t edit environment variables outside of an already running process (or at least without a debugger connected to that process). This is how programs we run have receive environment variables. The child process will load and run the new program, getting a copy of all existing environment variables (as well as access to file handles, etc). When you run a process, you’re actually forking the existing process, creating a parent and child. tmux allows you to run programs longer than your current SSH session, which causes a number of environment variables to go stale. Unfortunately, it’s power is also it’s failing. It allows you to create a running terminal instance that survives you logging out, letting you keep an editor setup running even if you disconnect. Tmux is a great tool to creates a persistent, splittable, shareable interface to a terminal. Remote ~ $ exit connection to remote closed. Remote ~ $ echo $SSH_AUTH_SOCK /tmp/ssh-ArPPCeB4Nm/agent.32382 Remote ~ $ echo $SSH_AUTH_SOCK /tmp/ssh-4ubDInuAFh/agent.30599 This temporary socket is wiped out when you end the SSH session (or the process ends by timing out), and you’ll get a new one the next time you SSH back in. It sets a few environment variables, primarily SSH_AUTH_SOCK. SSH forwards an agent by setting up a temporary socket file in your temp directory. You can use it by passing the -A flag to ssh. SSH has a nifty feature called “Agent Forwarding” that will forward key requests on remote servers through an SSH tunnel to a locally running ssh-agent process. Typing it in is tedious, so I use ssh-agent to store the credentials while I’m logged in. My GitHub key pairs are protected with a password. Somehow, tmux and ssh-agent are fighting over whether they can authenticate me. I use public keys to authenticate to GitHub. Please make sure you have the correct access rights Fatal: Could not read from remote repository.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |