Search code examples
centossftpssh-keysfilezilla

After setting ~/.bashrc the FileZilla doesn't work


To auto add ssh key I edited the ~/.bashrc file and added eval "$(ssh-agent -s)" and ssh-add at the end. It works well.

After doing this, I cannot visit the server via SFTP with FileZilla.

How can I fix this with keep auto running ssh-add?

My server OS is CentOS 6.7. I also access the server via shell.


Solution

  • The guy who answered your previous question¹ got something wrong: eval "$(ssh-agent -s)" should only be executed for login shells (e.g. when you are logging in over regular SSH to run commands on the server's command-line).

    Other tools, like FileZilla, may log in with non-interactive shells and these tools don't need or want the SSH Agent to be running.

    ~/.bashrc applies to both types of shells, so it is not the right place to start ssh-agent. ~/.bash_profile is a better choice since it only applies to login shells. Move the ssh-agent command there and everything should work again.

    ¹I'm that guy. Sorry for steering you wrong! I'll update that answer too.