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?

James Wright
  • 387
  • 1
  • 3
  • 13
  • What specific rc file do you mean by "my ssh rc"? Do you mean [.ssh/rc](https://man.openbsd.org/sshd#SSHRC)? or something like `.bashrc`? – Kenster Jul 29 '20 at 20:39
  • I mean `.ssh/rc`. – James Wright Jul 29 '20 at 22:02
  • 1
    Have you tried `if [ -t 0 ]; then …` or `if tty > /dev/null; then …`? P.S. [O’Reilly](https://www.oreilly.com/library/view/ssh-the-secure/0596008953/ch08s04.html) was literally the first result when I did [a Google search for “ssh rc”](https://www.google.com/search?q=ssh+rc). – Scott - Слава Україні Jul 30 '20 at 00: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. – James Wright Jul 30 '20 at 20:08

1 Answers1

0

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

.

ChennyStar
  • 1,319
  • 9
  • 22