This is well known problem that SSH client cannot connect to SSH-AGENT from SCREEN session. I will briefly refresh your memory on it. OpenSSH uses SSH_AGENT_SOCKET environment variable to connect SSH client and agent to get authentication data. The problem is, that SSH_AGENT_SOCKET is different each time you connect to host. But SCREEN session retains old value from the time session was first created. As a result SSH client inside SCREEN cannot use authentication keys from SSH-AGENT and asks for password.
There are already number of scripted solutions for this problem, that exist on the net. But none of what I found is fully working. I will skip delving into deficiencies of their implementations, but will try to deduce universal way of what should be done for coping with this problem. First, we need shell to be able to update SSH_AGENT_SOCKET before each command it executes. For example, in BASH it can be done by 'trap ... DEBUG'. Then, we need actual SSH_AGENT_SOCKET value for current running SCREEN session. And this is hardest and in fact impossible part to find it at runtime. Of course, we could lend to the method of leaving some traces upon SSH connection like do all the existing examples I've seen. But this, as was said, lacks universality and leads to deficiency of racing condition. What should we do to properly find SSH_AGENT_SOCKET, is to trace the path from the point of running shell inside SCREEN session to SSH connection that uses this session. And here what I found about what we can do and what we cannot do. The final goal is to find PID of SSH client. By knowing that PID we can easily find socket in /tmp/ssh-*$PID/agent.$PID and that will be the value for SSH_AGENT_SOCKET. To find PID of SSH we need to know PID of SCREEN client (i.e. 'screen -r' command). By knowning PID of SCREEN client we can easily find PID of SSH: walk through /proc filesystem. And what I could not find is how to find out PID of SCREEN client by PID of SCREEN daemon. The both are connected to SCREEN socket, but there is no permission to find all processes opening this socket. There is no commands inside SCREEN to find it. There is interactive command 'displays' that can be of some help: at least it displays used PTS, but there is no ability to run it in non-interactive way. Ideally, 'screen -list' should print instead of just '(Attached)' something like '(Attached to PID)'. And that would be enough to satisfy my needs. _______________________________________________ screen-users mailing list screen-users@gnu.org https://lists.gnu.org/mailman/listinfo/screen-users