<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://homeostasis.scs.carleton.ca/wiki/index.php?action=history&amp;feed=atom&amp;title=Operating_Systems_2020W_Lecture_8</id>
	<title>Operating Systems 2020W Lecture 8 - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://homeostasis.scs.carleton.ca/wiki/index.php?action=history&amp;feed=atom&amp;title=Operating_Systems_2020W_Lecture_8"/>
	<link rel="alternate" type="text/html" href="https://homeostasis.scs.carleton.ca/wiki/index.php?title=Operating_Systems_2020W_Lecture_8&amp;action=history"/>
	<updated>2026-06-02T22:24:20Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.42.1</generator>
	<entry>
		<id>https://homeostasis.scs.carleton.ca/wiki/index.php?title=Operating_Systems_2020W_Lecture_8&amp;diff=22573&amp;oldid=prev</id>
		<title>Soma: Created page with &quot;==Video==  The video from the lecture given on January 31, 2020 [https://homeostasis.scs.carleton.ca/~soma/os-2020w/lectures/comp3000-2020w-lec08-20200131.m4v is now available...&quot;</title>
		<link rel="alternate" type="text/html" href="https://homeostasis.scs.carleton.ca/wiki/index.php?title=Operating_Systems_2020W_Lecture_8&amp;diff=22573&amp;oldid=prev"/>
		<updated>2020-03-20T02:33:26Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;==Video==  The video from the lecture given on January 31, 2020 [https://homeostasis.scs.carleton.ca/~soma/os-2020w/lectures/comp3000-2020w-lec08-20200131.m4v is now available...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==Video==&lt;br /&gt;
&lt;br /&gt;
The video from the lecture given on January 31, 2020 [https://homeostasis.scs.carleton.ca/~soma/os-2020w/lectures/comp3000-2020w-lec08-20200131.m4v is now available.]&lt;br /&gt;
&lt;br /&gt;
==In-Class Notes==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Lecture 8&lt;br /&gt;
---------&lt;br /&gt;
Topics for today&lt;br /&gt;
 - ssh&lt;br /&gt;
 - usernames, groups, uid, gid&lt;br /&gt;
 - process id&amp;#039;s: uid, euid, fsuid&lt;br /&gt;
 - file permissions: read, write, execute&lt;br /&gt;
 - directory permissions&lt;br /&gt;
 - setuid, setgid&lt;br /&gt;
 - /etc/passwd, /etc/group, /etc/shadow&lt;br /&gt;
 - login process&lt;br /&gt;
&lt;br /&gt;
different kinds of user ID&amp;#039;s associated with a process:&lt;br /&gt;
 - uid: the original user ID&lt;br /&gt;
 - euid: &amp;quot;effective&amp;quot; uid, one used for determining privileges&lt;br /&gt;
         (e.g., what processes you can terminate)&lt;br /&gt;
 - fsuid: the uid used for accessing files&lt;br /&gt;
&lt;br /&gt;
fsuid is mostly used by file server programs, e.g. NFS, samba (CIFS on Linux)&lt;br /&gt;
 - we&amp;#039;ll ignore it from here on&lt;br /&gt;
&lt;br /&gt;
Normally euid=uid, but with setuid...euid becomes the uid of the executable&lt;br /&gt;
file, while the uid stays the same.&lt;br /&gt;
 - so euid generally becomes 0 (root) while the uid stays that of a regular&lt;br /&gt;
   process&lt;br /&gt;
&lt;br /&gt;
When a process does a system call, the kernel has to decide whether that system&lt;br /&gt;
call is authorized&lt;br /&gt;
 - normally it checks the process&amp;#039;s euid (and normally euid=uid) to see if this&lt;br /&gt;
   is allowed&lt;br /&gt;
 - if euid=0, almost everything is allowed (as this is root&amp;#039;s user ID)&lt;br /&gt;
 - regular users, you have to check the file permissions (for file access) or&lt;br /&gt;
   the uid of the process (for sending signals)&lt;br /&gt;
&lt;br /&gt;
to the operating system, there are only uid&amp;#039;s and gid&amp;#039;s, no usernames or groups&lt;br /&gt;
 - we have files defining the mapping of uid&amp;lt;-&amp;gt;usernames, gid&amp;lt;-&amp;gt;groups&lt;br /&gt;
&lt;br /&gt;
User accounts are in /etc/passwd&lt;br /&gt;
Groups are in /etc/group&lt;br /&gt;
&lt;br /&gt;
On most modern systems, there are NO PASSWORDS in /etc/passwd&lt;br /&gt;
 - there used to be&lt;br /&gt;
 - but having passwords in a file that is readable by everyone&lt;br /&gt;
   on the system is a bit of a security risk&lt;br /&gt;
 - nowadays, passwords are stored in /etc/shadow (a file that&lt;br /&gt;
   has restricted access)&lt;br /&gt;
&lt;br /&gt;
It is a pain to manually edit /etc/shadow and /etc/passwd and keep things&lt;br /&gt;
in sync.  So, if you want to do edits...&lt;br /&gt;
 - &amp;quot;shadowconfig off&amp;quot;&lt;br /&gt;
 - edit /etc/passwd, /etc/group&lt;br /&gt;
 - &amp;quot;shadowconfig on&amp;quot;&lt;br /&gt;
&lt;br /&gt;
No limit to the number of groups a user can be in, not sure about the&lt;br /&gt;
limit for how many users a group can have&lt;br /&gt;
 - all done by lookups in userspace so depends on the utilities, not&lt;br /&gt;
   the kernel&lt;br /&gt;
&lt;br /&gt;
How are passwords stored in /etc/shadow?&lt;br /&gt;
 - the $6$ prefix means they are encoded using SHA-512 (a variant of SHA-2)&lt;br /&gt;
 - the DES variant of original crypt is horribly insecure&lt;br /&gt;
 - and actually SHA-512 isn&amp;#039;t really that great, web apps normally use&lt;br /&gt;
   other functions&lt;br /&gt;
&lt;br /&gt;
You should have access to the &amp;quot;crypt(3)&amp;quot; man page, but it wasn&amp;#039;t&lt;br /&gt;
installed on my desktop for some reason&lt;br /&gt;
&lt;br /&gt;
The point of a secure hash:&lt;br /&gt;
 - easy to compute the hash&lt;br /&gt;
 - hard (infeasible) to find something that hashes to a given value&lt;br /&gt;
&lt;br /&gt;
So technically, you don&amp;#039;t have to guess someone&amp;#039;s password, you just&lt;br /&gt;
have to guess a string that has the same SHA-512 hash as their password&lt;br /&gt;
 - in practice this is the same thing&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If you stole password hashes (stole /etc/shadow or /etc/passwd with&lt;br /&gt;
password hashes stored in it), you can do an offline attack to guess&lt;br /&gt;
passwords&lt;br /&gt;
 - you just guess possible passwords, compute their hashes, and compare&lt;br /&gt;
   with the hashes in the password database&lt;br /&gt;
 - &amp;quot;salt&amp;quot; is added (a known string prefix) to each password so that&lt;br /&gt;
   two people with the same password don&amp;#039;t have the same hash, e.g.&lt;br /&gt;
&lt;br /&gt;
     alice has &amp;quot;banana&amp;quot; as password with salt &amp;quot;tacos&amp;quot;&lt;br /&gt;
        hash is of &amp;quot;tacosbanana&amp;quot;&lt;br /&gt;
     bob   has &amp;quot;banana&amp;quot; as password with salt &amp;quot;pizza&amp;quot;&lt;br /&gt;
        hash is of &amp;quot;pizzabanana&amp;quot;&lt;br /&gt;
&lt;br /&gt;
   alice and bob don&amp;#039;t have to remember their salt, it is generated&lt;br /&gt;
   automatically and stuck in the password file (appended to the hash&lt;br /&gt;
   string), so it isn&amp;#039;t any more secret than the hash&lt;br /&gt;
&lt;br /&gt;
NOTE THAT PASSWORD GUESSING PROGRAMS ARE VERY GOOD NOW&lt;br /&gt;
 - look up &amp;quot;john the ripper&amp;quot;&lt;br /&gt;
 - good at guessing common substitutions, e.g. numbers for letters&lt;br /&gt;
 - knows many dictionaries&lt;br /&gt;
 - and modern computers, with GPUs, can do a ridiculous number of guesses&lt;br /&gt;
 - and there are rainbow tables (precomputed tables of all possible password&lt;br /&gt;
   to hash mappings for up to like 12 characters)&lt;br /&gt;
&lt;br /&gt;
This means that if a password hash database is compromised, assume the attackers will crack all the passwords&lt;br /&gt;
 - so you hash, but try to keep it private&lt;br /&gt;
&lt;br /&gt;
note that no hash function has been proved to be hard to reverse,&lt;br /&gt;
we just think they are...until they aren&amp;#039;t&lt;br /&gt;
 - cryptographers keep breaking old hash functions&lt;br /&gt;
 - so always make your applications so they can change&lt;br /&gt;
 &lt;br /&gt;
note that secure hash functions are designed so a one bit change in input changes half the bits of the output on average&lt;br /&gt;
 - so small changes should lead to big hash differences&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
So once you type your password, the login process (or ssh or however you got in) has to:&lt;br /&gt;
 - create a child process&lt;br /&gt;
 - have it set up the environment for the new user&lt;br /&gt;
 - change the uid, gid to the new user&lt;br /&gt;
 - execve the user&amp;#039;s shell/startup program&lt;br /&gt;
&lt;br /&gt;
To perform administrative tasks as a regular user that have to modify&lt;br /&gt;
files owned by someone else (generally root)&lt;br /&gt;
 - the program binary should be setuid root (or setuid the user who&lt;br /&gt;
   has access to the file, or setgid to the group who has access)&lt;br /&gt;
&lt;br /&gt;
Note that secure hashes are often used as unique identifiers&lt;br /&gt;
 - even though technically they aren&amp;#039;t unique&lt;br /&gt;
 - e.g., certificates, change sets in git&lt;br /&gt;
 - when you look, secure hashes are everywhere&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
But now let&amp;#039;s talk about connecting to your VMs without passwords&lt;br /&gt;
&lt;br /&gt;
To do this, we identify ourselves using public key cryptography&lt;br /&gt;
 - instead of a password, we generate a public/private key pair&lt;br /&gt;
 - we are identified by the pubic key&lt;br /&gt;
 - we prove we are who we are by using the private key to answer&lt;br /&gt;
   challenges generated using the public key&lt;br /&gt;
&lt;br /&gt;
Better than passwords because if you tell anyone your password they know&lt;br /&gt;
your password (and thus can impersonate you)&lt;br /&gt;
 - note that the process on a system that accepts a password always&lt;br /&gt;
   sees its plaintext.  You don&amp;#039;t store it on disk (you just store the hash)&lt;br /&gt;
   but if the process is compromised the attacker can get the actual password&lt;br /&gt;
 - with public key crypto, the remote system NEVER has the private key,&lt;br /&gt;
   so there is nothing to steal that is confidential&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Whenever someone talks about digital signatures, code signing, certificates,&lt;br /&gt;
TLS/SSL - they are talking about technologies built on public key cryptography&lt;br /&gt;
&lt;br /&gt;
For example, let&amp;#039;s talk about SSH&lt;br /&gt;
 - can identify users using a password, but better&lt;br /&gt;
   to identify using a public-private key pair&lt;br /&gt;
 - generate keypair on local machine using ssh-keygen&lt;br /&gt;
 - copy public key to remote system&lt;br /&gt;
    - locally it is id_rsa.pub or similar&lt;br /&gt;
    - on remote system, add it to authorized_keys (can have multiple&lt;br /&gt;
      keys, one per line)&lt;br /&gt;
    - all files are in .ssh (note this directory should only be&lt;br /&gt;
      accessible by the user)&lt;br /&gt;
&lt;br /&gt;
authorized_keys stores public keys associated with a user&lt;br /&gt;
  (on remote system)&lt;br /&gt;
&lt;br /&gt;
known_hosts stores public keys associated with remote hosts&lt;br /&gt;
  (on local system)&lt;br /&gt;
&lt;br /&gt;
With ssh, remote hosts are identified by public/private key pairs&lt;br /&gt;
   OPTIONALLY, users can be identified by public/private key pairs&lt;br /&gt;
&lt;br /&gt;
this is the same with SSL/TLS&lt;br /&gt;
   - but almost nobody identifies users with public/private key pairs&lt;br /&gt;
     (i.e., certificates, not passwords)&lt;br /&gt;
   - if you use a secure token, though, this may be possible&lt;br /&gt;
&lt;br /&gt;
I expect you to know how to set up passwordless connections using ssh&lt;br /&gt;
   - because that is a super common use case in the cloud&lt;br /&gt;
the rest I&amp;#039;m not going to ask about&lt;br /&gt;
&lt;br /&gt;
And I expect you to understand accounts, uid, gid, etc&lt;br /&gt;
  - just not most of the crypto&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Soma</name></author>
	</entry>
</feed>