Is it possible to paste into the dom0 terminal?

There are many times I would like to cut and paste. Is this possible?

No. Pasting onto a terminal is a major security risk… and malicious commands in dom0 are the easiest way to get your whole system compromized. You should not do that even in appVM’s terminals. See the following to understand why:

https://thejh.net/misc/website-terminal-copy-paste

You should copy the file over to dom0, then read every line of it and finally execute (if really needed). Read more on the docs:

3 Likes

This is great advice.

No one should be afraid of asking here if there’s some detail in a script
they don’t understand. It could be really useful for other users. (You
should, of course try to understand it yourself before posting.)

2 Likes

I am just referring to text right now. Like if I’m installing a bunch of new items after reading something on this forum, I wish I could just cut and paste that text only instead of retyping it.

It’s a core part of dom0 that you should not be running programs in
dom0, and should not transfer files to dom0.
It is deliberately difficult to do this (to discourage users from
doing it), and should also be for management and the guiVM.

Sometimes, you do need to do something like this, and you can do it
without retyping.

What I would do is copy the text and paste it in to a plain text file in the qube.
Read it carefully and check you understand what it will do.
Transfer the file to dom0, using
qvm-run -p QUBE_NAME 'cat NAME_OF_FILE ' > NAME_IN_DOM0
Check the file again.
Run the commands, or change the configuration, or whatever it is you
want to do.

It’s somewhat cumbersome, but it’s dom0 that you are risking.

Good to know -p is the same as --pass-io. I had never noticed.

When you copy from a qube into the global clipboard (default shortcut ctrl+shift+c), the content of the clipboard becomes available in the following file:

/run/qubes/qubes-clipboard.bin

You can make the content available for the dom0 clipboard via xclip, f.e. like so:

< /run/qubes/qubes-clipboard.bin xclip -rmlastnl -selection clipboard

Depending on where you want to paste, you might want to sanitize the content of the clipboard somewhat. F.e. when pasting into a terminal you might want to get rid of any escape sequences which trigger unwanted functions from within your terminal. Also, characters looking very similar to more common character might pose a risk. So, you could add the following to the above pipe:

< /var/run/qubes/qubes-clipboard.bin iconv -t ascii//translit | tr -d \\33 | xclip -rmlastnl -selection clipboard

1 Like

Also, Xfce-terminal has a nice option that should be checked by default - Show Unsafe Paste Dialog (maybe it even is, I’m not sure), so I admit that I am probably overlooking something why this wouldn’t be enough to safely cut’n’paste into Xfce-terminal at least…
For me it works perfectly, and as advertised.