Showing posts from August, 2013

SUDO - sudo: /etc/sudoers is mode 0755, should be 0440 error

Sudoers is a policy file to determine who and what you can run with sudo command. When sudo command is executed, it will check it permission and make sure it is only at read only mode 0440.

Sudoers file is owned by Root and should only be changed by Root. So, if you encounter error such as

sudo: /etc/sudoers is mode 0755, should be 0440

That means someone, most likely Root, had changed the permission of Sudoers file.
A lot of post said that you need reboot PC, boot into recovery mode, etc.. but they are overkill.
If you are a normal user, report this to your Root administrator.
If you have access to Root account, do the following
1. Login to Root as super user via su command. It will require you to enter Root password
su root
2. cd to /etc
cd /etc
3. Change the permission for the file
chmod 0440 sudoers
4. Exit super user mode
That all. You do not need to reboot or boot into recovery mode at all.

NTP Timestamp Reloaded

As I am still getting questions regarding NTP Timestamp calculation, I should reload this topic and provide more detail information 
About NTP Timestamp
1. NTP timestamp uses 64 bits representation and consists of 2 parts, first 32-bits is the Integer Part that represent the seconds and the next 32-bits is the Fraction Part that represent fractional of a second
According and referencing RFC 958 for point 2 and 3
NTP timestamps are represented as a 64-bit fixed-point number, in seconds relative to 0000 UT on 1 January 1900 (See Point 2). The integer  part is in the first 32 bits and the fraction part in the last 32 bits, as shown in the following diagram. 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Integer Part | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+…

SUDO - Retain Root Environment Variable

Just a note to remind myself instead of searching on Google all the time

As always, when I tried to sudo a command that requires Root environment variable, the OS will tell me that environmental variable is not set. This is because sudo reset environment variable to prevent leakage of Root information due to security reason

If you have some environment variable such as

export XXX=/usr/local/XXX/

and if you perform a command require XXX environment variable

sudo xxx_cmd

you will have problem running it.

2 ways to solve this issue

Using sudo -E

You can use -E options in sudo to preserve environment variable. This will override env_reset option in sudoers.

sudo -E xxx_cmd

This is a quick one time command to execute a command that require Root environment variable

Modifying /etc/sudoers

sudoers file contains a list of rules on which users may execute what when sudo command is executed.

There is a whole list of things you can do with sudoers file, but, I will not be going through here. Plea…

Cygwin - Install SSH Server in Cygwin

Sometime, you will want to have SSH server running in Cygwin. In order to run SSH server in Cygwin, you will need SSH Daemon (sshd) to be configured.

Below are some steps to configure Cygwin to run sshd

1. Open Cygwin and run ssh-host-config

2. During the configuration, it will ask the following question

a) Should privileges separation be used?

Enter yes

b) New local account 'sshd'?

Enter yes

c) Do you want to install sshd as a service?

Enter yes. This will allow you to log into Cygwin even when Cygwin window is not running

d) Enter the value of Cygwin for the daemon?

Enter ntsec

e) "cyg_server' will only be used by registered services. Do you want to use a different name?

Enter no. Default work well

f) Please enter the password

Enter a password for cyg_server user

g) After this, the installation should be complete.

h) Type net start sshd to start the service

i) Now, you can use any SSH client to connect to your Cygwin sshd via localhost with port 22