I accidentally just locked myself out of my pi while editing /etc/ssh/sshd_config. The pi is still mounted as a drive on my desktop via sshfs so I looked at sshd_config and I can see that I accidentally left UsePAM blank. Now ssh connections are refused :(

I have a monitor, mouse and keyboard nearby so I plugged them in, but HDMI hot-swapping is not enabled by default apparently. So all I have is a blank screen. I also noted that after plugging in the keyboard, I could not get the numlock light to turn on so I'm not even sure if the keyboard and mouse are working.

I found this post that suggests the possibility of turning on HDMI explicitly with this command:

tvservice --explicit="DMT 35 HDMI"

I also found this post that says tvservice is not the best way to turn the monitor on/off, and instead I should use

vcgencmd display_power 1

However, I can't see the screen to see what I'm doing.

What keys should I type after I plug in the keyboard, mouse, and monitor?

Note: I absolutely cannot reboot this raspberry pi because I have the longest uptime in my friend group and this earns me one free beer per week. I have to exhaust every possibility before I reboot.

  • 1
    you need figure out what to type, and hope :D Commented May 19, 2017 at 4:52

2 Answers 2


Rereading your post, I now know mine won't help, but I'm leaving it in the case that I'm wrong, or for future searchers with similar problems. My problem was losing my graphical display connected to my TV after the display went to "sleep" (just X, no display manager). xrandr was the tool that saved me.

Try sudo xrandr -d :0 --output HDMI-1 --mode 1920x1080. Use the name of the output to which you are connected and the resolution desired. For --output, I've seen "HDMI-1", "eDP-1", "HDMI" and "eDP". If you need to type a password for sudo, don't forget to type it after the command. :)

If you're unsure if xrandr is installed, issue sudo apt-get install xrandr before issuing the above command to ensure that it's installed. Give those a try. Good luck!


Take the SD card out of the pi, put it in your laptop, edit sshd_config, change the usePAM line, and you're good to go!

  • This doesn't answer the question. If you take the SD card out, you will have to reboot the RPi. The question asks how to do it without a reboot.
    – Chenmunka
    Commented Jul 1, 2021 at 18:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.