0

It is possible to print QR Codes on a console using for instance this solution. There are other methods available on github too, but all of them end up displaying UTF8 chars. Therefore, I think that the challenge is in displaying a stdout on the TTY1 from the remote host

The remote host is a linux deployment without X, it has connectivity, allows me to ssh, I'm able to become a super-user and it has a local monitor connected displaying the login prompt on TTY1 (which is where I want to print the QR code).

4
  • Displaying a QR code needs some kind of graphical display. This might be a common graphical desktop environment or maybe some platform specific method like Linux framebuffer. The main point of the question is how to display a graphics image file, e.g. a .png file on your remote system. Please edit your question and add more details about the remote system: hardware, OS, graphical user environment or other available software to display graphical output.
    – Bodo
    Commented Jul 18, 2022 at 14:42
  • A graphics image is not required to display a QR code. There are apps to display qr codes on consoles. Several examples can be found on GitHub or even right here. Commented Jul 18, 2022 at 14:54
  • If you want to use an application that can display a QR code on a console (of what system?), please edit your question and add all details, including links to the applications you already know of. Even if my assumption about using graphical display is wrong, the question lacks details about the system and your requirements.
    – Bodo
    Commented Jul 18, 2022 at 15:02
  • OK, I think it's done now. Let me know if you feel it lacks any additional detail Commented Jul 18, 2022 at 15:13

1 Answer 1

0

To print to another terminal, you just print to /dev/ttyN or /dev/pts/N (where N is a number). If you want TTY1 then use /dev/tty1.

As a regular user you cannot print to a terminal that is not yours. In general you need sudo. However sudo qrencode -t ascii foo > /dev/tty1 is not a good method because it's your unelevated shell who tries to open /dev/tty1 before sudo starts. These are proper ways:

qrencode -t ascii foo | sudo tee /dev/tty1
sudo sh -c 'qrencode -t ascii foo > /dev/tty1'

Note the latter method runs sh and qrencode as root, while the former method runs only tee as root, nothing more. Prefer the former method then. Add >/dev/null after tee /dev/tty1 to suppress printing to your tty.

1
  • Thank you! This test command worked like a charm: ssh user@host 'qrencode -t ansiutf8 < qrcodefile | doas tee /dev/tty1' >/dev/null Commented Jul 18, 2022 at 15:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .