2

if I ssh in to my Pi that has a tv attached to the svideo I can set tty1 writable but it does not seem to "see" the input, the characters just appear on the screen.

sudo chmod 666 /dev/tty1
echo msg1 > /dev/tty1

I understand that it is a security risk to be able to write characters to the login shell, but how can I do it?

I want to be able to see characters I send and then have them accepted as if a keyboard was attached.

Is it just a getty security "thing"? If I set up automated login would I be able to execute "ls" etc directly on tty1?

6
  • 1
    Couldn't you just print the command to tty1, and then run the command from ssh, and forward the output to tty1. That way the end result would be about the same. Except maybe missing the pi@raspberrypi ~ $ in front on the command, but you could just fake that by also printing that.
    – Gerben
    Oct 29, 2013 at 16:10
  • @Gerben that is shear genius! Worked perfectly and so simple. Set it as an answer and I will accept it. Now I need to find a way of setting stdout to /dev/tty1, but that is a separate issue.
    – rob
    Oct 30, 2013 at 8:49
  • Does somecommand > /dev/tty1 not work?
    – Gerben
    Oct 30, 2013 at 15:48
  • yep that works but I would rather not add >/dev/tty1 for every command I enter, in fact what would be ideal is instead of setting stdout to /dev/tty1 is to also send anything from stdout to /dev/tty1 so I keep a copy in my ssh session as well as it appearing on the Pi's screen.
    – rob
    Oct 30, 2013 at 20:28
  • 1
    @Gerben that only seems to work for scripts, but I found a simple way. bash 2>&1 | tee /dev/tty1 Creates a new shell with all the STDOUT and STDERR being copied to TTY1. The only downside is you do not see the prompt on the other screen.
    – rob
    Nov 3, 2013 at 21:26

3 Answers 3

0

Couldn't you just print the command to tty1, and then run the command from ssh, and forward the output to tty1.

That way the end result would be about the same. Except maybe missing the pi@raspberrypi ~ $ in front on the command, but you could just fake that by also printing that.

1
  • This doesn't allow control of programs that need to run on "real" terminals like fbi .
    – Samveen
    Sep 29, 2021 at 7:14
2

I would use screen in this situation. Start a screen session, then attach to it on both the console and on the remote machine.

2
  • 1
    And as always, try tmux if you want to use screen. It's like the better version of screen.
    – Arne
    Oct 29, 2013 at 8:29
  • This doesn't work for programs that require a "REAL" terminal, like fbi. Those check information on the terminal using IOCTLs, which cannot be emulated by virtual terminals as created by screen or tmux .
    – Samveen
    Sep 29, 2021 at 7:11
2

Old thread, I know.

I had a need for this exact situation, so I wrote a program for it. Using uinput, I forward my ssh connection to the console keyboard (and soon, console mouse too!).

Effectively, it connects your keyboard directly to the RPi, as if you were typing on a USB keyboard plugged into the RPi. Certainly interesting to type on my laptop, and see the output on the bigscreen, as if I were typing on the RPi itself.

I have some plans for this utility, it's usefulness is growing as I play with it. I'm planning on forwarding the mouse events too, so really you could use keyboard & mouse on a remote computer (not just RPi!), great for demonstrations and show&tell type things.

Disclaimer: I wrote this. Good, Bad, or just plain Ugly, it's my fault.

fauxcon - fake console connection

3
  • 1
    could come in handy :) Jul 16, 2014 at 7:34
  • 1
    Very handy! I've been using it to run a text mode music player on RPi, which is displayed on my HDMI TV, rather than in my terminal window on laptop. Not shovelling tons of data across network to display app. Works with X Windows too, just need to get mouse events passed through and then my laptop/computer will act as a wireless keyboard/mouse for RPi. (or any other system!). Basically, I wanted 'run over there, display over THERE'... rather than the 'run over there, display over HERE' you usually get with ssh. (gosh! it's just a simple 'T'... that's the answer!)
    – lornix
    Jul 16, 2014 at 8:06
  • Perfect solution to work fbi on tty1 mirrored (fast) to a SPI display using fbcp-ili9341.
    – Samveen
    Sep 29, 2021 at 11:17

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.