Sichuanren's Blog

March 20, 2015

Works from Isabel and her grandpa

Filed under: Life — Tags: — sichuanren @ 10:39 pm

image

存在的喜悦

Filed under: Uncategorized — sichuanren @ 10:34 pm

如果在你正在做的事情中没有喜悦、 自在和轻松, 这并不意味着你需要改变你正在做的事情,而是需要改变你做事的方式。如何做事通常比做什么事更为重要。

SEEQS from Queens university

Filed under: Uncategorized — sichuanren @ 10:34 pm

grade 8 to 12, summer time, one program, one week.

March 5, 2015

Using “guestfish” to change the Password for the root account

Filed under: Uncategorized — sichuanren @ 7:29 pm

Using “guestfish” to change the Password for the root account

You can use guestfish to edit a running system under KVM virtualization:
– You can use “guestfish” to edit the /etc/shadow file and change the root password.
Guestfish is an interactive shell that you can use from the command line or from shell scripts to access guest virtual machine file systems. (See example below):

  • If needed, first install the guestfish rpm.
  • Red Hat Enterprise Linux 7.x (This command will not work on Fedora, If you are using Fedora Linux, see next block)
yum -y install guestfish
  • Fedora Linux (This command will not work on Red Hat Enterprise Linux 7, it is intended for Fedora Linux)
yum -y install libguestfs-tools
  • Import the qcow2 image into KVM. The image will be named something along the lines of: “rhel-guest-image-7.0-20140506.1.x86_64.qcow2”, (as of June 23rd, 2014, the version will of course change over time)
    • Change the password on the newly imported KVM to get on the pre-built system.

Example steps to change the root password using guestfish:
– This set of instructions is for use on the host system that has the kvm RHEL 7 guest. The following is from Red Hat solution ID 641193
– The syntax is: guestfish –rw -a <image-name>
(Note, your system may be /dev/vda1, mine was /dev/sda1. Use the ‘list-filesystems’ command)


root@box1 # guestfish --rw -a ./rhel-7-public-beta-x86_64-kvm.qcow2
><fs> run
><fs> list-filesystems
><fs> mount /dev/sda1 /
><fs> vi /etc/shadow
### Remove the 2nd field so that skip the root password and use passwd to set it after you are in
NOTE: after you perform the following steps you use "quit" to exit. 
DO NOT EXIT NOW, proceed with the following steps
  • Replace the encrypted password (add it while you are still in vi).
    This will set the password for the image permanently.
  • An encrypted password can be created using the openssl command (see an example below).

NOTE: Open a separate terminal window to create an encrypted password with the openssl command (see example just below)

Separate window, different terminal window

[root@someothersystem ~]# openssl passwd -1 changeme
$1$QiSwNHrs$uID6S6qOifSNZKzfXsmQG1

  • There is a vi session open from the guestfish session mentioned above.
  • Copy the output of the openssl command above and appropriately place it into the /etc/shadow file you have opened with vi.

When done type “quit”

22.6. TERMINAL MENU EDITING DURING BOOT

Menu entries can be modified and arguments passed to the kernel on boot. This is done using the menu entry editor interface, which is triggered when pressing the e key on a selected menu entry in the boot loader menu. The Esc key discards any changes and reloads the standard menu interface. The c key loads the command line interface.
The command line interface is the most basic GRUB interface, but it is also the one that grants the most control. The command line makes it possible to type any relevant GRUB commands followed by the Enter key to execute them. This interface features some advanced features similar to shell, including Tab key completion based on context, and Ctrl+a to move to the beginning of a line and Ctrl+e to move to the end of a line. In addition, the arrow, Home, End, and Delete keys work as they do in the bash shell.

22.6.1. Booting to Rescue Mode

Rescue mode provides a convenient single-user environment and allows you to repair your system in situations when it is unable to complete a normal booting process. In rescue mode, the system attempts to mount all local file systems and start some important system services, but it does not activate network interfaces or allow more users to be logged into the system at the same time. In Red Hat Enterprise Linux 7, rescue mode is equivalent to single user mode and requires the root password.
  1. To enter rescue mode during boot, on the GRUB 2 boot screen, press the e key for edit.
  2. Add the following parameter at the end of the linux line on 64-Bit IBM Power Series, the linux16 line on x86-64 BIOS-based systems, or the linuxefi line on UEFI systems:
    systemd.unit=rescue.target
    Press Ctrl+a and Ctrl+e to jump to the start and end of the line, respectively. On some systems, Home and End might also work.
    Note that equivalent parameters, 1, s, and single, can be passed to the kernel as well.
  3. Press Ctrl+x to boot the system with the parameter.

22.6.2. Booting to Emergency Mode

Emergency mode provides the most minimal environment possible and allows you to repair your system even in situations when the system is unable to enter rescue mode. In emergency mode, the system mounts the root file system only for reading, does not attempt to mount any other local file systems, does not activate network interfaces, and only starts few essential services. In Red Hat Enterprise Linux 7, emergency mode requires the root password.
  1. To enter emergency mode, on the GRUB 2 boot screen, press the e key for edit.
  2. Add the following parameter at the end of the linux line on 64-Bit IBM Power Series, the linux16 line on x86-64 BIOS-based systems, or the linuxefi line on UEFI systems:
    systemd.unit=emergency.target
    Press Ctrl+a and Ctrl+e to jump to the start and end of the line, respectively. On some systems, Home and End might also work.
    Note that equivalent parameters, emergency and -b, can be passed to the kernel as well.
  3. Press Ctrl+x to boot the system with the parameter.

22.6.3. Changing and Resetting the Root Password

Setting up the root password is a mandatory part of the Red Hat Enterprise Linux 7 installation. If you forget or lose the root password it is possible to reset it, however users who are members of the wheel group can change the root password as follows:

~]$ sudo passwd root
Note that in GRUB 2, resetting the password is no longer performed in single-user mode as it was in GRUB included in Red Hat Enterprise Linux 6. The root password is now required to operate in single-user mode as well as in emergency mode.
Two procedures for resetting the root password are shown here:
  • Procedure 22.1, “Resetting the Root Password Using an Installation Disk” takes you to a shell prompt, without having to edit the grub menu. It is the shorter of the two procedures and it is also the recommended method. You can use a boot disk or a normal Red Hat Enterprise Linux 7 installation disk.
  • Procedure 22.2, “Resetting the Root Password Using rd.break” makes use of rd.break to interrupt the boot process before control is passed from initramfs to systemd. The disadvantage of this method is that it requires more steps, includes having to edit the GRUB menu, and involves choosing between a possibly time consuming SELinux file relabel or changing the SELinux enforcing mode and then restoring the SELinux security context for /etc/shadow/ when the boot completes.

Blog at WordPress.com.