Which profile, .bashrc or .bash_profile, is the appropriate spot for ssh-agent? I'm looking for an answer that explains the different between an interactive shell and a login shell.
Ssh – .bashrc or .bash_profile for ssh-agent
bashbashrcssh
Related Topic
- Ssh – Why does bash invocation differ on AIX when using telnet vs ssh
- Linux – What are the functional differences between .profile .bash_profile and .bashrc
- Bash – Both bashrc and bash_profile won’t seemingly source? VirtualMin Clean install
- Linux – Use .bashrc without breaking sftp
- Linux – Where is $BASH_ENV usually set
- Ubuntu – Straight forward way to run ssh-agent and ssh-add on login via SSH
- Ssh – bashrc not loaded in /bin/bash shell
- Ssh – shell script for running ssh-agent
Best Answer
It depends somewhat on how you personally use shells.
An interactive shell is anything that has a terminal connected to its input and output. Login shells are spawned by /bin/login. Login shells source your .bash_profile. Most terminal emulators such as xterm start an interactive shell that is not a login shell. Interactive, non-login shells source your .bashrc.
What I typically do is have my .bash_profile source my .bashrc (after checking if it has already been sourced), and then I put my ssh-agent setup in my .bashrc.