简体   繁体   中英

ssh connections are spawning hundreds of ssh-agent /bin/bash instances

I have an Arch server running on a VMWare VM. I connect to it through a Firewall that forwards ssh connections from port X to port 22 on the server. Yesterday, I started receiving the error "Bash: Fork: Resource Temporarily Unavailable". I can log in as root and manage things without problem, but it seems that when I ssh in as the user I normally use, the ssh session is now spawning hundreds of ssh-agent /bin/bash sessions. This is, in turn, using up all the threads and file descriptors (from what I can tell) on the system and making it unusable. The little bit of info I've been able to find thus far tells me that I must have some sort of loop, but this hasn't happened until yesterday, possibly when I ran updates. At this point, I am open to suggestions.

One of your shell initialization files is probably spawning a shell, which, when reading the shell initialization files will spawn a shell, etc.

You mentioned ssh-agent /bin/bash . Putting this in .bashrc will definitely cause problems, as this instructs ssh-agent to spawn bash ...

Instead, use something like

if [[ -z "$SSH_AUTH_SOCK" ]]; then
  eval $(ssh-agent)
fi

in .bashrc (or .xinitrc or .xsession for systems with graphical logins).

Or possibly (untested):

if [[ -z "$SSH_AUTH_SOCK" ]]; then
  ssh-agent /bin/bash
fi

in .bash_profile .

in my case (windows) it was because i was not exiting when done with a shell, so they were not getting disposed.

when done use ctrl+d or type exit to terminate the ssh agent

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM