I asked on stackoverflow for my problem. And i will ask here too…

Does anybody know, what the problem could be?

  • Fuck Lemmy.World @lemmy.world
    link
    fedilink
    English
    arrow-up
    7
    ·
    2 years ago

    I just tested this on three Debian 12 VMs, two computers running Arch and one running Rocky 8. In all cases the socket file gets removed as soon as the first ssh-agent process is killed, so I can’t reproduce your case where the socketfile remains.

    user@bookworm:~$ ssh-agent -a ~/.ssh/my-agent -t 7200
    SSH_AUTH_SOCK=/home/user/.ssh/my-agent; export SSH_AUTH_SOCK;
    SSH_AGENT_PID=51401; export SSH_AGENT_PID;
    echo Agent pid 51401;
    user@bookworm:~$ rm .ssh/my-agent 
    user@bookworm:~$ ssh-agent -a ~/.ssh/my-agent -t 7200
    SSH_AUTH_SOCK=/home/user/.ssh/my-agent; export SSH_AUTH_SOCK;
    SSH_AGENT_PID=51411; export SSH_AGENT_PID;
    echo Agent pid 51411;
    user@bookworm:~$ kill 51401
    user@bookworm:~$ ls .ssh/my-agent
    ls: cannot access '.ssh/my-agent': No such file or directory
    

    Running an strace on the first ssh-agent pid produces something like:

    strace: Process 51401 attached
    restart_syscall(<... resuming interrupted poll ...>) = ? ERESTART_RESTARTBLOCK (Interrupted by signal)
    --- SIGTERM {si_signo=SIGTERM, si_code=SI_USER, si_pid=2407, si_uid=1026} ---
    getpid()                                = 51401
    unlink("/home/user/.ssh/my-agent")    = 0
    exit_group(2)                           = ?
    +++ exited with 2 +++
    

    I would be curious to see what strace shows on your machine where the socketfile does not get deleted. Does it show an unlink, but does it fail for some reason? Or doesn’t it attempt to unlink at all?

    • WhyAUsername_1@lemmy.world
      link
      fedilink
      arrow-up
      2
      ·
      2 years ago

      Please feel free to ignore my comment, if it’s too basic.

      What is socketfile?

      I have been using ssh for a couple of years, this is the first time I am hearing about socket file. Also, why is it’s deletion at the end of session relevant?

      Thanks in advance.

      • Fuck Lemmy.World @lemmy.world
        link
        fedilink
        arrow-up
        2
        ·
        2 years ago

        What is socketfile?

        A socket file allows two processes on a Unix or Linux system to communicate with each other. In this case, the ssh client communicates with the ssh agent over this socket so that it can authenticate to servers with the private key stored inside the agent. Think of a socket like a TCP port on the network, but instead of being network connected it’s just a file on the filesystem.

        I’m sure you’ve heard of the “everything on Unix is a file” paradigm? This is an example of that.

        Also, why is it’s deletion at the end of session relevant?

        That is a question you should ask OP. I don’t really know what he’s trying to accomplish, I’m just curious about what would cause the difference in behavior.