]> www.opopop.net Git - reminder/blob - recovering_when_locked_out_from_your_computer.mdwn
attachment upload
[reminder] / recovering_when_locked_out_from_your_computer.mdwn
1 This is a howto on regaining control of your Linux computer when
2 you messed up your normal way to interact with it: keyboard, mouse,
3 video or network access.
4
5 # You can't interact with your computer anymore
6
7 You switched video mode and lost your mouse. Or the screen is suddenly
8 blank or freezed. Or you keyboard input echoes garbage. Or if you use
9 a server, you can't no more ssh to it.
10
11 Your computer is in most likelihood still working ok under the hood,
12 and there are quite always better ways to recover than to reboot cold.
13
14 ## Keyboard input echoes garbage
15
16 Most likely culprit is wrong configuration of your tty device. This is
17 not critical as you can always switch tty. In general, typing Ctrl-V
18 Ctrl-O will restore sane values.
19
20 I encountered one time a garbage case on a linux console, which was solved by:
21
22     echo -e \\033c
23
24 More details to be found [here](http://www.tldp.org/HOWTO/Keyboard-and-Console-HOWTO-4.html).
25
26 ## Mouse invisible or unusable because moving erratically
27
28 The mouse invisible can happen inside some sophisticated applications
29 (e.g.: some versions of VirtualBox). The best way here is, after
30 possibly switching console, to stop the faulty application.
31
32 If the mouse seems moving too fast or too slowly, try changing mouse
33 parameters with tools like xset, or their highlevel desktop cousins.
34 For instance, in Gnome, look for Mouse in the System/Preferences menu.
35
36 An erratically moving mouse may indicate, as with keyboard garbage,
37 that the mouse device is badly configured; this used to happen in the
38 past with serial mice. This can also happen if you use the mouse both
39 in X and the console with gpm. 
40
41 In nothing of the above solves the issue, restarting the X system may
42 be needed, see below.
43
44 ## Mouse pointer freezed or keyboard unresponsive
45
46 This can happen with a USB mouse or keyboard, especially if:
47
48 1. You use a KVM switch or
49 2. You have switched to a linux console and back to X
50
51 Other symptoms: the leds on the keyboard don't change when you hit caps lock, 
52 or the leds on keyboard or mouse are off. Simply unplug and plug again the device 
53 can solve the issue. 
54
55 You can verify after the fact that syslog contains messages about USB  disconnections 
56 of these devices. I know no real definite solution to these issues. 
57
58 ## Screen is freezed or blank
59
60 Switch to a console, stop cleanly your graphical applications if
61 possible, then restart the X system. If you use gdm, this is how to do
62 it on a Debian system: 
63
64     /usr/sbin/invoke-rc.d gdm stop
65     /usr/sbin/invoke-rc.d gdm start
66
67 ## Nothing solves the issue: trying the network
68
69 If nothing of the above works, and you can't even get a text console
70 by hitting Shift-Alt-F1, you may connect to your computer through
71 telnet, ssh... That is, you have telnetd or sshd running on it. If not
72 see below.
73
74 ## Nothing solves the issue: trying a serial link
75
76 The file controlling where to start login processes is /etc/inittab. 
77 You will have something like that inside:
78
79     1:2345:respawn:/sbin/getty 38400 tty1
80     2:23:respawn:/sbin/getty 38400 tty2
81     #T0:23:respawn:/sbin/getty -L ttyS0 9600 vt100
82
83 The 2 first lines will give you a login prompt at the screen
84 (reachable with Alt-F1 and Alt-F2 in text mode, and with Shift-Alt-F1
85 and Shift-Alt-F2 in graphical mode).
86
87 The last one (in general commented out with the #), will start getty
88 on a serial device. Using a second computer running a tool like
89 minicom and linking it using a null modem to the first one, you will
90 get a login prompt on that second computer screen to allow
91 troubleshoot the first one.
92
93 What if the line is commented out, what is a null modem, what to do if
94 I have no serial port, and how do I configure minicom? Answers in next
95 section.
96
97 # Computer control recovery preparation using a serial link 
98
99 So my advice to maximize your odds to cleanly regain control of your
100 computer is to prepare for that case in advance, by allowing a serial
101 link login. A serial link login has not the security problem of
102 allowing network access. 
103
104 ## No serial port on my computer
105
106 Except for servers, the rule now is no serial port. But the rule is
107 also to have USB everywhere, and luckily hardware converters
108 serial/link exist. Linux has drivers for a lot of these converters,
109 and you should have no problem getting one, see for instance:
110 [[http://www.gooze.eu/catalog/embedded-components/cables]]
111
112 The Linux driver creates a device name like /dev/ttyUSB0 instead of
113 /dev/ttyS0.
114
115 ## Starting a login process on my serial port
116
117 You have to edit and uncomment the line in /etc/inittab. Line:
118
119     #T0:23:respawn:/sbin/getty -L ttyS0 9600 vt100
120
121 becomes in case of a serial/usb converter:
122
123     T0:23:respawn:/sbin/getty -L ttyUSB0 9600 vt100
124
125 You must force the init process to take into account the modified file
126 by issuing command:
127
128     telinit q
129
130 ## The null modem
131
132 The link above about serial/usb converters offers also null modems.
133 If you don't mind a bit of soldering, it's quite easy to
134 [build one yourself](http://www.lammertbies.nl/comm/info/RS-232_null_modem.html).
135
136 ## Minicom configuration
137
138 What is needed at the other end of our serial link is a dumb serial
139 terminal. It happens that if you don't have one in your attic, you
140 can emulate one with a second computer. Minicom is one of these
141 emulators.
142
143 At that point, you may also discover that you don't have a serial port
144 either on that second computer! Time to go shopping for a second
145 serial/usb converter... It's of course possible to have a serial port
146 on the blocked computer and none on the terminal emulator.
147
148 So when you have all the hardware, you can install and configure
149 minicom. Notice that you will have to run minicom as root, or give
150 lax permissions to your serial devices. Minicom configuration file 
151 is called /etc/minicom/minirc.dfl under Debian and should contain:
152
153     pu port             /dev/ttyS0
154     pu baudrate         9600
155     pu bits             8
156     pu parity           N
157     pu stopbits         1
158     pu minit            
159     pu mreset           
160     pu rtscts           No
161
162 You should only have to change the first line to adapt of your specific serial device name.
163 You may have to hit CR to get the login prompt.
164
165 ## If everything fails
166
167 Nothing of the above works? You are in for a reboot, but if the
168 keyboard driver is still alive, you can still get a more a less clean
169 shutdown using the [SysRq](http://www.linuxhowtos.org/Tips%20and%20Tricks/sysrq.htm).