利用BusyBox定制Linux Live CD
Create the necessary files in "etc". Exit out of root at this point, so that there is no chance of over-writing you system "/etc" -- note disaster is only a "/" away. WARNING: Never copy anything into a directory that starts with "/", since that is your current running system. [Exit out of root] The "etc/passwd" file is shown below. Since the ssh daemon will run, an account will be created for it. Note for sshd that login is set to "/bin/false" [etc/passwd] root:x:0:0:Linux User,,,:/root:/bin/sh sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/bin/false Below "root" and "sshd" have been added to the group. [etc/group] root:x:0:root sshd:x:74: Note below that there is a password for the account root. This encrypted password is "root". You could create your own password here by copying an existing account password from "/etc/shadow" and "/etc/shadow-". The account "sshd" should have "*" for the password. [etc/shadow] root:$1$$oCLuEVgI1iAqOA8pwkzAg1:12439:0:99999:7::: sshd:*:11880:0:99999:7:-1:-1:0 [etc/shadown-] root:$1$$hCYnkWaG0VVCE9xJiIJwU/:12439:0:99999:7::: sshd:*:11880:0:99999:7:-1:-1:0 Interesting question regarding sshd: Why is "/dev/pts" necessary when sshing into this computer? If you are uncertain, remove this line and observe the results of the command "ps aux", when attempting to ssh in. [etc/fstab] /dev/ram0 / ext2 defaults 0 0 proc /proc proc defaults 0 0 sysfs /sys sysfs defaults 0 0 none /dev/pts devpts gid=5,mode=620 0 0 The file "etc/inittab" is called by the init program. There are no run levels with BusyBox. The lines "tty2::respawn:/sbin/getty 38400 tty2" allow you to enter "ctl-alt-F2" and get a login screen. [etc/inittab] # This is run first except when booting in single-user mode. # ::sysinit:/etc/init.d/rcS # # ::respawn:/sbin/getty 38400 tty1 # # /sbin/getty invocations for selected ttys # #tty1::respawn:/sbin/getty 38400 tty1 tty2::respawn:/sbin/getty 38400 tty2 tty3::respawn:/sbin/getty 38400 tty3 tty4::respawn:/sbin/getty 38400 tty4 tty5::respawn:/sbin/getty 38400 tty5 tty6::respawn:/sbin/getty 38400 tty6 tty7::respawn:/sbin/getty 38400 tty7 tty8::respawn:/sbin/getty 38400 tty8 tty9::respawn:/sbin/getty 38400 tty9 # # # Example of how to put a getty on a serial line (for a terminal) # #::respawn:/sbin/getty -L ttyS0 9600 vt100 #::respawn:/sbin/getty -L ttyS1 9600 vt100 # # Example how to put a getty on a modem line. #::respawn:/sbin/getty 57600 ttyS2 # # Stuff to do when restarting the init process ::restart:/sbin/init # # Stuff to do before rebooting ::ctrlaltdel:/sbin/reboot ::shutdown:/bin/umount -a -r ::shutdown:/sbin/swapoff -a Note above, "inittab" calls "etc/init.d/rcS". The ram drive must be remounted; otherwise, it will be read only. Also, when the system boots, DHCP will be enabled. If the computer is not going to be connected to the network, comment this out, since it will repeatedly attempt to acquire an IP address. Also, if the proper NIC (Network Interface Card) is not found, you will inundated with messages. [etc/init.d/rcS] #!/bin/sh /bin/mount -a # below getting rid of ram being mounted ro /bin/mount -o remount / # # The following is for dhcp # ifconfig eth0 0.0.0.0 /sbin/udhcpc # # Instead, if you want static IP address # #ifconfig eth0 192.168.1.13 netmask 255.255.252.0 #route add default gw 192.168.1.1 # # Run ssh daemon /sbin/sshd The file below, along with libraries /lib/libnss_* are necessary for password authentication, since the recent version of GNU Libc (glibc) uses Name Service Switch (NSS). This file can probably be copied from your system's "/etc/nsswitch.conf" file. If you don't have this file on your system, take the necessary files from "proj1.tar.gz". [etc/nsswitch.conf] # # /etc/nsswitch.conf # # An example Name Service Switch config file. This file should be # sorted with the most-used services at the beginning. # # The entry '[NOTFOUND=return]' means that the search for an # entry should stop if the search in the previous entry turned # up nothing. Note that if the search failed due to some other reason # (like no NIS server responding) then the search continues with the # next entry. # # Legal entries are: # # nisplus or nis+ Use NIS+ (NIS version 3) # nis or yp Use NIS (NIS version 2), also called YP # dns Use DNS (Domain Name Service) # files Use the local files # db Use the local database (.db) files # compat Use NIS on compat mode # hesiod Use Hesiod for user lookups # [NOTFOUND=return] Stop searching if not found so far # # To use db, put the "db" in front of "files" for entries you want to be # looked up first in the databases # # Example: #passwd: db files nisplus nis #shadow: db files nisplus nis #group: db files nisplus nis passwd: files shadow: files group: files #hosts: db files nisplus nis dns hosts: files dns # Example - obey only what nisplus tells us... #services: nisplus [NOTFOUND=return] files #networks: nisplus [NOTFOUND=return] files #protocols: nisplus [NOTFOUND=return] files #rpc: nisplus [NOTFOUND=return] files #ethers: nisplus [NOTFOUND=return] files #netmasks: nisplus [NOTFOUND=return] files bootparams: nisplus [NOTFOUND=return] files ethers: files netmasks: files networks: files protocols: files rpc: files services: files netgroup: files publickey: nisplus automount: files aliases: files nisplus 更多相关文章
|
推荐文章
精彩文章
|