问题
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.
回答1:
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.
来源:https://stackoverflow.com/questions/34428134/after-setting-bashrc-the-filezilla-doesnt-work