Not really, but I know what you&#x27;re experiencing.<p>The ssh agent forwarding info is stored in environment variables, which are then inherited by any other process spawned from your initial connection, so everything that cares knows the agent pid and where to find the agent socket.<p>The problem is that, with screen and tmux, the content of those environment variables outlasts their accuracy.<p>The solution needs to take the form of updating those environment variables.  It looks like there&#x27;s a .ssh_agent file that can be sourced to update it, though I&#x27;m not finding - at a skim of the docs - what creates that and when.  It does only seem to contain info for a single socket, so assuming it&#x27;s populated on login there&#x27;s still a possibility of that data being stale:<p><pre><code>    connection 1 login
    connection 1 writes info to file
    connection 2 login
    connection 2 writes info to file
    connection 2 logout
</code></pre>
leaves the info wrong if you try to use it from connection 1.<p>Better would be to store <i>all</i> active agent sessions.  We can implement that as follows:<p>in .bash_profile:<p><pre><code>    if [ &quot;$SSH_AUTH_SOCK&quot; -a &quot;$SSH_AGENT_PID&quot; ]; then
        exec {SSH_AGENT_INFOS_FD}&gt;&gt;~&#x2F;.ssh_agent_infos
        if flock $SSH_AGENT_INFOS_FD; then
            sed -i &quot;1i$SSH_AGENT_PID $SSH_AUTH_SOCK&quot; ~&#x2F;.ssh_agent_infos
        fi
        exec {SSH_AGENT_INFOS_FD}&gt;&amp;-
    fi
</code></pre>
This creates the file if it doesn&#x27;t exist, locks it, and prepends the current session&#x27;s info.  It goes in .bash_profile, <i>not</i> .bashrc, so that it is only executed for login shells.<p>in .bash_logout:<p><pre><code>    if [ &quot;$SSH_AUTH_SOCK&quot; -a &quot;$SSH_AGENT_PID&quot; ]; then
        flock .ssh_agent_infos sed -i &quot;&#x2F;^$SSH_AGENT_PID &#x2F;d&quot; .ssh_agent_infos
    fi
</code></pre>
This locks the file and strips out lines with a matching PID.  .bash_logout is sourced on exit from a login shell.<p>in .bashrc, set BASH_PROMPT so that it includes the following (personally, my BASH_PROMPT is set to source ~&#x2F;.bash_prompt):<p><pre><code>    exec {SSH_AGENT_INFOS_FD}&gt;&gt;~&#x2F;.ssh_agent_infos
    if flock -w 1 -s $SSH_AGENT_INFOS_FD; then
        read -u $SSH_AGENT_INFOS_FD SSH_AGENT_PID SSH_AUTH_SOCK
    fi
    exec {SSH_AGENT_INFOS_FD}&gt;&amp;-
</code></pre>
This will run every time a new prompt is generated (so, right  after running the previous command, if any).  It locks the file, and then reads the first line out of it to populate SSH_AGENT_ID and SSH_AUTH_SOCK.  So if a shell has old values in those variables, you should just need to hit enter to repopulate them.<p>Note that the above assumes that, if you&#x27;re logging in from multiple devices, your agents are interchangeable.  If you need to keep them separate, then adjust the above to either tag the lines in .ssh_agent_infos or use multiple files.