2

I just installed Ubuntu Server 22.04 and SSHed in. I'm not able to paste multiple sudo commands as I could with Ubuntu Server 20.04. This feels to me like a security feature that I don't want.

Previously (before 22.04) I could manually enter sudo -v and then paste some sudo commands and I'd get:

user@host:~$ sudo -v
[sudo] password for user:
user@host:~$ sudo mkdir test
user@host:~$ sudo rm -r test
user@host:~$ ls
user@host:~$

Now, with 22.04, I get:

user@host:~$ sudo -v
[sudo] password for user:
user@host:~$ sudo mkdir test
sudo rm -r test
user@host:~$ ls
test

How can I change this behavior?

Edit:

After trying what's suggested in this answer, I still get the same results. I did try pasting a second time after doing bind 'set enable-bracketed-paste off'.

user@host:~$ sudo -v
user@host:~$ bind 'set enable-bracketed-paste off'
user@host:~$ bind -v | grep bracketed
set enable-bracketed-paste off
user@host:~$ sudo -v
user@host:~$ sudo mkdir test
sudo rm -r test
user@host:~$ ls
test
user@host:~$

Edit 2:

I also ran xterm via ssh and X forwarding from my Mac and got the same results as a regular ssh connection.

10
  • If you want to use multiple commands via sudo, why not use sudo -i and then just enter the commands into root shell without prefixing them with sudo? Why do you want to prefix each command separately with sudo?
    – raj
    May 9, 2022 at 16:32
  • 2
    Does this answer your question? Pasted text in Gnome Terminal in 21.04 is always highlighted
    – vanadium
    May 9, 2022 at 16:36
  • you just never got a prompt after the first sudo command
    – Esther
    May 9, 2022 at 16:40
  • 3
    @raj because it is best practice to use sudo only when you need to run a command that actually needs the privileges. Elevating the whole shell to the root user is not good practice and increases the surface area for very costly mistakes.
    – Nmath
    May 9, 2022 at 18:05
  • 1
    In that answer, it is indicated to change the paste behavior back to how it previously was.
    – vanadium
    May 9, 2022 at 19:39

2 Answers 2

1

It's due to the addition of Defaults use_pty in /etc/sudoers, comment out the line to revert to the previous behaviour.

1
  • This saved me. How is this not upvoted 100 times? Isn't Ubuntu the most popular Linux distribution in the world? How can hundreds if not thousands of people be impacted by this? Thank you. Jan 5, 2023 at 5:19
0

Why not trying with

user@host:~$ sudo bash

and then write all your commands?

1
  • 1
    Welcome to Ask Ubuntu! That's covered in the comments, along with several reasons, "Why not." Dec 26, 2022 at 22:14

You must log in to answer this question.

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