0

I have my ssh rc (~/.ssh/rc)on a remote machine setup to start ssh-agent and ssh-add any public keys present. When I try and scp to this machine, it will attempt to prompt for the pass keys, then the scp will fail and exit.

Ideally, I would like the ssh-agent and ssh-add to only occur for interactive ssh sessions. Is there a way in the ssh rc to determine whether the session is interactive and selectively run (or not run) certain commands in response?

4
  • What specific rc file do you mean by "my ssh rc"? Do you mean .ssh/rc? or something like .bashrc?
    – Kenster
    Jul 29 '20 at 20:39
  • I mean .ssh/rc. Jul 29 '20 at 22:02
  • 1
    Have you tried if [ -t 0 ]; then … or if tty > /dev/null; then …? P.S. O’Reilly was literally the first result when I did a Google search for “ssh rc”.
    – Scott
    Jul 30 '20 at 0:52
  • @Scott I did when I was originally looking for .ssh/rc information, but ended up following a different tutorial. Thanks for the pointer, I'll see if that works for me. Jul 30 '20 at 20:08
0

Just check if the environment variable SSH_TTY is set. See how to distinguish ssh from scp in ~/.ssh/rc?

.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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