strange folder in /tmp with name ssh-*

5,350

Solution 1

The folder contains sockets used by programs to communicate with ssh-agent:

From the man page:

$TMPDIR/ssh-XXXXXXXXXX/agent.< ppid >
    UNIX-domain sockets used to contain the connection to the
    authentication agent.  These sockets should only be readable by
    the owner.  The sockets should get automatically removed when the
    agent exits.

Solution 2

Florian's answer is correct. However, if you find a lot of them building up, you can put this file in your $HOME/.bash_logout file:

[ -n "$SSH_AGENT_PID" ] &&
    ps -p "${SSH_AGENT_PID}" >/dev/null 2>&1 | grep ssh-agent &&
    kill "${SSH_AGENT_PID}"

I'm not sure if they remain due to a bug, or if that's how ssh-agent is designed. But on some of our systems we see old ssh-agent processes left running and those files left under /tmp. Killing the agent process should remove the /tmp/ssh-whatever directory and files, but if it doesn't on your system, you could add a line to check and remove it based on $SSH_AUTH_SOCK.

Share:
5,350

Related videos on Youtube

Fat Mind
Author by

Fat Mind

Updated on September 18, 2022

Comments

  • Fat Mind
    Fat Mind over 1 year

    while i do ls to the /tmp i found these files what is the meaing of the ssh folder i found

    /tmp$ ls 
    config-err-pBxjic
    e5a28b00f2378661cc615788a1fef225-{87A94AB0-E370-4cde-98D3-ACC110C5967D}
    gnome-software-TQ809Y
    ssh-Rony2Zd8gQ6O
    systemd-private-a789ca0968fb4855b28539acfbf9babe-colord.service-UCNgBR
    systemd-private-a789ca0968fb4855b28539acfbf9babe-fwupd.service-4Xkw4W
    systemd-private-a789ca0968fb4855b28539acfbf9babe-rtkit-daemon.service-KmLgj9
    systemd-private-a789ca0968fb4855b28539acfbf9babe-systemd-resolved.service-F55I3N
    systemd-private-a789ca0968fb4855b28539acfbf9babe-systemd-timesyncd.service-W5W5Kx
    unity_support_test.0
    
    /tmp$ cd ssh-Rony2Zd8gQ6O/
    /tmp/ssh-Rony2Zd8gQ6O$ ls 
    agent.1616
    /tmp/ssh-Rony2Zd8gQ6O$ cat agent.1616 
    cat: agent.1616: No such device or address
    

    so what is the meaning of the existence of this folder and it's content

    • Videonauth
      Videonauth over 6 years
      Did you use ssh lately? I have a similar folder here containing a symbolic link agent.1909=
    • Fat Mind
      Fat Mind over 6 years
      no i didn't use SSH at all from this machine
    • Videonauth
      Videonauth over 6 years
      O.k. check the output of systemctl --state running | grep ssh
    • RonJohn
      RonJohn over 6 years
      I'd run ls -aFl. That will show whether or not agent.116 is a special file.
  • Fat Mind
    Fat Mind over 6 years
    so you mean it's normal ?