這是本文件的舊版!
How to login to OS automatically?
Windows
Preface
Windows要做到自動登入,不同版本Windows其實大同小異。但有一個最重要的是:必須是正版的Windows,否則會跳出盜版之類的訊息。
Method 1
Modify Registry
新增三個Type String的Registry到\KEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon中,
AutoAdminLogin: 1
DefaultUserName: administrator
DefaultPassword: 123456
AutoAdminLogin為開啟自動登入;DefaultUserName為登入帳號;DefaultPassword為登入密碼。
Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon] "AutoAdminLogon"="1" "DefaultUserName"="Administrator" "DefaultPassword"="123456"
Modify Local Security Policy
在Windows2003或2008中,因為安全性的考量,系統會將一些設定disable/enable。為了達到AutoLogin我們必須去關掉某些設定。
首先到Administrative Tools>Local Security Policy中,如果不想常常改密碼,可以將Account Policies>Password Policy中的Minimum password age修改為0。
接著將Local Policies>Security Option中的Interactive logon: Do not require CTRL+ALT+DEL給Enable。在啟動系統後就不會要求你要先輸入CTRL+ALT+DEL才能Login。
Method 2
透過control userpasswords2指令去設定。
http://www.lhu.edu.tw/i/teach-online/xp_autologin.htm
在Win7、XP、Win2008 R2上測試過可行。
Method 3
執行以下script,default user名稱可根據喜好自行決定是否使用。
reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v AutoAdminLogon /t REG_SZ /d 1 /f reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v DefaultUserName /t REG_SZ /d administrator /f
Linux
Preface
Linux的自動登入最為複雜,會因為它版本、Distribution的不同,而要有不同的修改。
RHEL&CentOS 5.x
#vim /etc/inittab id:3:initdefault: 1:2345:respawn:/sbin/mingetty --autologin root tty1 #vim /root/.bash_profile if [ -z "$DISPLAY" ] && [ "$(tty)" = "/dev/tty1" ] then startx fi
RHEL&CentOS 6.x
Method 1
- 修改/etc/inittab
id:3:initdefault
- 修改/etc/init/tty.conf
stop on runlevel [2345] respawn instance /dev/tty1 exec /sbin/mingetty --noclear --autologin=root /dev/tty1
- 執行
echo "startx" >> /root/.bash_profile
Method 2
修改/etc/gdm/custom.conf
[daemon] AutomaticLoginEnable=True AutomaticLogin=rootAutomaticLogin填的是要自動登入的user名稱。
SLES11
Reference