I've some rules in .ssh/config file which I would like activate only in interactive mode (ie. terminal background change). Is that possible?

  • Could you be more specific about what you are trying to achieve? I suggest that you include the relevant parts of the two config files. – 200_success Sep 20 at 17:01
  • What's your definition of interactive? Do you mean whether a command has been passed to the ssh command or not? Or are you referring to the use of any of the flags -t, -T, -N? – kasperd Sep 20 at 17:09
up vote 4 down vote accepted

You can alias ssh if using a non-interactive shell as follows in your ~/.bashrc file:

    if [ -z "$PS1" ]; then
        alias ssh='ssh -F ~/.ssh/config-non-interactive'

... then copy the non-interactive configuration you'd like to use to ~/.ssh/config-non-interactive and you should be set.

  • When this is combined with Include I think it will be a flexible way of utilising config files. superuser.com/a/1142813 . There were many times I gave up on certain config features because it wasn’t compatible across my workstations. – sdkks Sep 20 at 14:19

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.