<?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_2021F%3A_Tutorial_5</id>
	<title>Operating Systems 2021F: Tutorial 5 - 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_2021F%3A_Tutorial_5"/>
	<link rel="alternate" type="text/html" href="https://homeostasis.scs.carleton.ca/wiki/index.php?title=Operating_Systems_2021F:_Tutorial_5&amp;action=history"/>
	<updated>2026-04-06T04:53:16Z</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_2021F:_Tutorial_5&amp;diff=23429&amp;oldid=prev</id>
		<title>Soma: /* Tasks */</title>
		<link rel="alternate" type="text/html" href="https://homeostasis.scs.carleton.ca/wiki/index.php?title=Operating_Systems_2021F:_Tutorial_5&amp;diff=23429&amp;oldid=prev"/>
		<updated>2021-11-02T15:37:44Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Tasks&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 15:37, 2 November 2021&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l119&quot;&gt;Line 119:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 119:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# Setup password-less login to your local system between the student and other account (or any two other accounts), following the above instructions.  Note that the &amp;quot;local&amp;quot; account is the one you are running the ssh command on.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# Setup password-less login to your local system between the student and other account (or any two other accounts), following the above instructions.  Note that the &amp;quot;local&amp;quot; account is the one you are running the ssh command on.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# Setup password-less login to access.scs.carleton.ca, following the instructions above.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# Setup password-less login to access.scs.carleton.ca, following the instructions above.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# Secure shell can be used to directly run a command on another program rather than the default shell.  For example, try &quot;ssh student@localhost bc -l&quot; and see that bc is run.  When you do this, does ssh directly run the specified command or does it first run a shell and have the shell run the command?  Use opensnoop.bt to verify.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# Secure shell can be used to directly run a command on another program rather than the default shell.  For example, try &quot;ssh student@localhost bc -l&quot; and see that bc is run.  When you do this, does ssh directly run the specified command or does it first run a shell and have the shell run the command?  Use opensnoop&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;.bt or execsnoop&lt;/ins&gt;.bt to verify.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# What files in /etc does bash access when you login via 3000userlogin?  How does this compare to what bash opens when you log in via ssh?&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# What files in /etc does bash access when you login via 3000userlogin?  How does this compare to what bash opens when you log in via ssh?&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# &amp;#039;&amp;#039;&amp;#039;(Optional):&amp;#039;&amp;#039;&amp;#039; Prompt for the user&amp;#039;s password before logging the user in.  To do this, you&amp;#039;ll need to get the right password hash and then figure out how to hash the entered password to check if it matches.  See online guides about [https://www.slashroot.in/how-are-passwords-stored-linux-understanding-hashing-shadow-utils how passwords are stored on Linux] for help.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# &amp;#039;&amp;#039;&amp;#039;(Optional):&amp;#039;&amp;#039;&amp;#039; Prompt for the user&amp;#039;s password before logging the user in.  To do this, you&amp;#039;ll need to get the right password hash and then figure out how to hash the entered password to check if it matches.  See online guides about [https://www.slashroot.in/how-are-passwords-stored-linux-understanding-hashing-shadow-utils how passwords are stored on Linux] for help.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Soma</name></author>
	</entry>
	<entry>
		<id>https://homeostasis.scs.carleton.ca/wiki/index.php?title=Operating_Systems_2021F:_Tutorial_5&amp;diff=23424&amp;oldid=prev</id>
		<title>Soma at 18:01, 22 October 2021</title>
		<link rel="alternate" type="text/html" href="https://homeostasis.scs.carleton.ca/wiki/index.php?title=Operating_Systems_2021F:_Tutorial_5&amp;diff=23424&amp;oldid=prev"/>
		<updated>2021-10-22T18:01:30Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 18:01, 22 October 2021&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l1&quot;&gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&#039;&#039;&#039;This tutorial is still in development.&#039;&#039;&#039;&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-added&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-added&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;In this tutorial you will learn about how accounts and logging in work through exploring 3000userlogin and ssh.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;In this tutorial you will learn about how accounts and logging in work through exploring 3000userlogin and ssh.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Soma</name></author>
	</entry>
	<entry>
		<id>https://homeostasis.scs.carleton.ca/wiki/index.php?title=Operating_Systems_2021F:_Tutorial_5&amp;diff=23423&amp;oldid=prev</id>
		<title>Soma: /* Code */</title>
		<link rel="alternate" type="text/html" href="https://homeostasis.scs.carleton.ca/wiki/index.php?title=Operating_Systems_2021F:_Tutorial_5&amp;diff=23423&amp;oldid=prev"/>
		<updated>2021-10-22T17:59:23Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Code&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 17:59, 22 October 2021&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l127&quot;&gt;Line 127:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 127:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Code==&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Code==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[https://homeostasis.scs.carleton.ca/~soma/os-&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;2020w&lt;/del&gt;/code/&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;tut4&lt;/del&gt;.tar.gz Download code for this tutorial (3000userlogin.c and Makefile)]&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[https://homeostasis.scs.carleton.ca/~soma/os-&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;2021f&lt;/ins&gt;/code/&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;3000userlogin&lt;/ins&gt;.tar.gz Download code for this tutorial (3000userlogin.c and Makefile)]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;===3000userlogin.c===&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;===3000userlogin.c===&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Soma</name></author>
	</entry>
	<entry>
		<id>https://homeostasis.scs.carleton.ca/wiki/index.php?title=Operating_Systems_2021F:_Tutorial_5&amp;diff=23422&amp;oldid=prev</id>
		<title>Soma: /* Tasks */</title>
		<link rel="alternate" type="text/html" href="https://homeostasis.scs.carleton.ca/wiki/index.php?title=Operating_Systems_2021F:_Tutorial_5&amp;diff=23422&amp;oldid=prev"/>
		<updated>2021-10-22T17:37:00Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Tasks&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 17:37, 22 October 2021&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l118&quot;&gt;Line 118:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 118:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# How important is each of the environment variables that is set by 3000userlogin?  Are these the only environment variables that are set after you successfully login?&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# How important is each of the environment variables that is set by 3000userlogin?  Are these the only environment variables that are set after you successfully login?&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# Note that 3000userlogin uses environ not envp (as an argument to main) to access environment variables.  Why not use envp?  (Try changing the code to use envp and see what happens.)&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# Note that 3000userlogin uses environ not envp (as an argument to main) to access environment variables.  Why not use envp?  (Try changing the code to use envp and see what happens.)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;What &lt;/del&gt;system calls is &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;3000userlogin &lt;/del&gt;using to change its uid &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;and gid&lt;/del&gt;?  &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;What arguments do they take, and how do they &lt;/del&gt;compare to &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;those of &lt;/del&gt;the &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;library wrappers that we are using?  (Note that you won&#039;t be able to strace or run gdb as &lt;/del&gt;a &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;regular &lt;/del&gt;user&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;; instead, log &lt;/del&gt;in &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;as root and run strace or gdb).&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Use &amp;lt;tt&amp;gt;bpftrace /usr/local/share/bpftrace/tools/setuids.bt&amp;lt;/tt&amp;gt; to see what &lt;/ins&gt;system calls &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;3000userlogin &lt;/ins&gt;is using to change its uid&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;.  Is it what you expect given the source of 3000login&lt;/ins&gt;?  &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;How does this &lt;/ins&gt;compare to the &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;system calls ssh uses when &lt;/ins&gt;a user &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;logs &lt;/ins&gt;in&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;? &lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# Setup password-less login to your local system between the student and other account (or any two other accounts), following the above instructions.  Note that the &amp;quot;local&amp;quot; account is the one you are running the ssh command on.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# Setup password-less login to your local system between the student and other account (or any two other accounts), following the above instructions.  Note that the &amp;quot;local&amp;quot; account is the one you are running the ssh command on.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# Setup password-less login to access.scs.carleton.ca, following the instructions above.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# Setup password-less login to access.scs.carleton.ca, following the instructions above.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# Secure shell can be used to directly run a command on another program rather than the default shell.  For example, try &quot;ssh student@localhost bc -l&quot; and see that bc is run.  When you do this, does ssh directly run the specified command or does it first run a shell and have the shell run the command?  How &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;can &lt;/del&gt;you &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;verify what is happening&lt;/del&gt;?&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# Secure shell can be used to directly run a command on another program rather than the default shell.  For example, try &quot;ssh student@localhost bc -l&quot; and see that bc is run.  When you do this, does ssh directly run the specified command or does it first run a shell and have the shell run the command&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;?  Use opensnoop.bt to verify.&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;# What files in /etc does bash access when you login via 3000userlogin&lt;/ins&gt;?  How &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;does this compare to what bash opens when &lt;/ins&gt;you &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;log in via ssh&lt;/ins&gt;?&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# &amp;#039;&amp;#039;&amp;#039;(Optional):&amp;#039;&amp;#039;&amp;#039; Prompt for the user&amp;#039;s password before logging the user in.  To do this, you&amp;#039;ll need to get the right password hash and then figure out how to hash the entered password to check if it matches.  See online guides about [https://www.slashroot.in/how-are-passwords-stored-linux-understanding-hashing-shadow-utils how passwords are stored on Linux] for help.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# &amp;#039;&amp;#039;&amp;#039;(Optional):&amp;#039;&amp;#039;&amp;#039; Prompt for the user&amp;#039;s password before logging the user in.  To do this, you&amp;#039;ll need to get the right password hash and then figure out how to hash the entered password to check if it matches.  See online guides about [https://www.slashroot.in/how-are-passwords-stored-linux-understanding-hashing-shadow-utils how passwords are stored on Linux] for help.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Soma</name></author>
	</entry>
	<entry>
		<id>https://homeostasis.scs.carleton.ca/wiki/index.php?title=Operating_Systems_2021F:_Tutorial_5&amp;diff=23421&amp;oldid=prev</id>
		<title>Soma: /* Setup */</title>
		<link rel="alternate" type="text/html" href="https://homeostasis.scs.carleton.ca/wiki/index.php?title=Operating_Systems_2021F:_Tutorial_5&amp;diff=23421&amp;oldid=prev"/>
		<updated>2021-10-22T16:20:01Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Setup&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 16:20, 22 October 2021&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l50&quot;&gt;Line 50:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 50:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;===Setup===&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;===Setup===&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Install the openssh-server package (note on openstack it will already be installed, but on a default Ubuntu &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;18.04 &lt;/del&gt;install it won&#039;t be):&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Install the openssh-server package (note on openstack it will already be installed, but on a default Ubuntu &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;desktop &lt;/ins&gt;install it won&#039;t be):&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  sudo apt-get install openssh-server&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  sudo apt-get install openssh-server&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Soma</name></author>
	</entry>
	<entry>
		<id>https://homeostasis.scs.carleton.ca/wiki/index.php?title=Operating_Systems_2021F:_Tutorial_5&amp;diff=23419&amp;oldid=prev</id>
		<title>Soma: Created page with &quot;&#039;&#039;&#039;This tutorial is still in development.&#039;&#039;&#039;  In this tutorial you will learn about how accounts and logging in work through exploring 3000userlogin and ssh.  ==Logging in to...&quot;</title>
		<link rel="alternate" type="text/html" href="https://homeostasis.scs.carleton.ca/wiki/index.php?title=Operating_Systems_2021F:_Tutorial_5&amp;diff=23419&amp;oldid=prev"/>
		<updated>2021-10-21T14:03:01Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;&amp;#039;&amp;#039;&amp;#039;This tutorial is still in development.&amp;#039;&amp;#039;&amp;#039;  In this tutorial you will learn about how accounts and logging in work through exploring 3000userlogin and ssh.  ==Logging in to...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&amp;#039;&amp;#039;&amp;#039;This tutorial is still in development.&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
In this tutorial you will learn about how accounts and logging in work through exploring 3000userlogin and ssh.&lt;br /&gt;
&lt;br /&gt;
==Logging in to a UNIX system==&lt;br /&gt;
&lt;br /&gt;
In order to log in to a UNIX system (Linux or otherwise), the following steps must occur (potentially not in this order).&lt;br /&gt;
&lt;br /&gt;
# The user must authenticate themselves, proving their identity and that they are allowed to access the system.  By default this is done through a username and password.&lt;br /&gt;
# A new process, U, should be created for the authenticated user.&lt;br /&gt;
# The login program must establish communication with the user via some communications channel.  Normally this channel will be a device.  Standard in, out, and error for U should be connected to this device.&lt;br /&gt;
# U changes uid and gid to that of the new user.&lt;br /&gt;
# U sets up other aspects of the user&amp;#039;s context (mainly setting key environment variables).&lt;br /&gt;
# U does an execve of the user&amp;#039;s chosen shell.&lt;br /&gt;
&lt;br /&gt;
[[#Code|3000userlogin]] is a basic implementation of steps 4-6.   (Steps 2 and 3 are accomplished by running 3000userlogin in a shell, as running an external command means the shell first creates a new process, as we have seen.  We are skipping 1.)&lt;br /&gt;
&lt;br /&gt;
When 3000userlogin is properly compiled and set up, you can run&lt;br /&gt;
&lt;br /&gt;
  ./3000userlogin someuser&lt;br /&gt;
&lt;br /&gt;
and you&amp;#039;ll be logged in as &amp;quot;someuser&amp;quot;, assuming someuser exists.&lt;br /&gt;
&lt;br /&gt;
You can add a user with the adduser command.  For example, to create the user &amp;quot;someuser&amp;quot;:&lt;br /&gt;
&lt;br /&gt;
  sudo adduser someuser&lt;br /&gt;
&lt;br /&gt;
Note you&amp;#039;ll have to answer several questions.&lt;br /&gt;
&lt;br /&gt;
If you just compile 3000userlogin normally, you won&amp;#039;t be able to log in as anyone except the current user.  To compile and set up 3000userlogin, do the following:&lt;br /&gt;
&lt;br /&gt;
  gcc -O -Wall 3000userlogin.c -o 3000userlogin&lt;br /&gt;
  sudo chown root:root 3000userlogin&lt;br /&gt;
  sudo chmod u+s 3000userlogin&lt;br /&gt;
&lt;br /&gt;
The chown command makes the binary owned by root, and the chmod command makes it setuid.  Thus, when the program is execve&amp;#039;d it will have an effective user ID of root (euid=0).&lt;br /&gt;
&lt;br /&gt;
Alternately, you can download the code and use the associated makefile to build by doing the following:&lt;br /&gt;
&lt;br /&gt;
  wget https://homeostasis.scs.carleton.ca/~soma/os-2020w/code/tut4.tar.gz&lt;br /&gt;
  tar xzf tut4.tar.gz&lt;br /&gt;
  cd tut4&lt;br /&gt;
  make&lt;br /&gt;
  make setuid&lt;br /&gt;
&lt;br /&gt;
==SSH==&lt;br /&gt;
&lt;br /&gt;
Here you will be learning about [http://www.openssh.org ssh (openssh)], the standard program for accessing UNIX systems remotely.  It is a more secure replacement for older technologies such as [https://en.wikipedia.org/wiki/Berkeley_r-commands rsh] and [https://en.wikipedia.org/wiki/Telnet telnet].&lt;br /&gt;
&lt;br /&gt;
===Setup===&lt;br /&gt;
&lt;br /&gt;
Install the openssh-server package (note on openstack it will already be installed, but on a default Ubuntu 18.04 install it won&amp;#039;t be):&lt;br /&gt;
&lt;br /&gt;
 sudo apt-get install openssh-server&lt;br /&gt;
&lt;br /&gt;
Create a second user in the virtual machine named &amp;quot;other&amp;quot; (or any other name you wish to use):&lt;br /&gt;
&lt;br /&gt;
 sudo adduser other&lt;br /&gt;
&lt;br /&gt;
(Answer the subsequent prompts however you wish, just remember the password.)&lt;br /&gt;
&lt;br /&gt;
At this point you should be able to log in to the &amp;quot;other&amp;quot; account using ssh:&lt;br /&gt;
&lt;br /&gt;
 ssh other@localhost&lt;br /&gt;
&lt;br /&gt;
You&amp;#039;ll have to enter your password.&lt;br /&gt;
&lt;br /&gt;
If you don&amp;#039;t get a password prompt, password authentication has probably been disabled.  (Password authentication has been disabled on the openstack VMs.)  To enable it, do the following&lt;br /&gt;
&lt;br /&gt;
  sudo nano /etc/ssh/sshd_config    (or vi, or emacs)&lt;br /&gt;
&lt;br /&gt;
In the editor change the line &amp;quot;PasswordAuthentication no&amp;quot; to &amp;quot;PasswordAuthentication yes&amp;quot;.  Then, to restart sshd:&lt;br /&gt;
&lt;br /&gt;
  sudo service sshd restart&lt;br /&gt;
&lt;br /&gt;
Be sure to change it back after you&amp;#039;ve set up public key authentication!&lt;br /&gt;
&lt;br /&gt;
===Public key authentication and ssh===&lt;br /&gt;
&lt;br /&gt;
Create a public key file for your account (as user student, ubuntu, or your personal account):&lt;br /&gt;
&lt;br /&gt;
 ssh-keygen&lt;br /&gt;
&lt;br /&gt;
(Accept the default filename and choose at least a simple passphrase.)&lt;br /&gt;
&lt;br /&gt;
You just created a certificate!  (A certificate is just a public key with metadata.)&lt;br /&gt;
&lt;br /&gt;
Copy the key to the other account:&lt;br /&gt;
&lt;br /&gt;
 cat ~/.ssh/id_rsa.pub &amp;gt;&amp;gt; authorized_keys&lt;br /&gt;
 scp authorized_keys other@localhost:.&lt;br /&gt;
 rm authorized_keys&lt;br /&gt;
 ssh other@localhost&lt;br /&gt;
&lt;br /&gt;
 (as user other)&lt;br /&gt;
 mkdir ~/.ssh (if it doesn&amp;#039;t exist already)&lt;br /&gt;
 chmod 700 ~/.ssh  (make it private)&lt;br /&gt;
 mv ~/authorized_keys ~/.ssh&lt;br /&gt;
 chmod 600 ~/.ssh/authorized_keys&lt;br /&gt;
&lt;br /&gt;
Now you can log in to user other by typing in the passphrase you used to lock the key you generated.&lt;br /&gt;
&lt;br /&gt;
To avoid entering this passphrase every time, you can give it to the authentication agent (generally, ssh-agent) that was started when you logged in:&lt;br /&gt;
&lt;br /&gt;
  ssh-add&lt;br /&gt;
&lt;br /&gt;
Note I expect the above to be a bit confusing.  Do look around for resources on public key cryptography; however, you may find that playing around with ssh authentication may help you understand things better.  In particular, try using &amp;quot;-v&amp;quot; (verbose) with ssh.&lt;br /&gt;
&lt;br /&gt;
==Tasks==&lt;br /&gt;
&lt;br /&gt;
# Compile and setup 3000userlogin as described above.  Create a new user account.  Verify that you can use 3000userlogin to login as the new user without typing the password of the new user.&lt;br /&gt;
# What is returned as the user&amp;#039;s password by getpwnam()?  Is this what you expected?&lt;br /&gt;
# Compare the uid, gid, euid, egid when running 3000userlogin as a regular user, running it setuid root, and running it as root (i.e., running it from a root shell without the setuid bit set).  Also check to see what happens when you set the setgid bit (with different group IDs on the file).&lt;br /&gt;
# Why does 3000userlogin change its gid before changing its uid?  What happens if you switch the order of these operations?&lt;br /&gt;
# Make 3000userlogin use the shell that is specified in the user&amp;#039;s password entry.  Check by making a new user and setting its shell to a new shell and then see if that new shell runs when you run 3000userlogin.  You can change a user&amp;#039;s shell with the chsh command.&lt;br /&gt;
# Can you set 3000shell to be a user&amp;#039;s default shell?  What changes do you have to make for chsh to accept 3000shell?  Does anything obvious break when running 3000shell this way, and how can you change 3000userlogin to fix it?&lt;br /&gt;
# Does a user&amp;#039;s default shell have to be a regular shell?  Could it instead be an arbitrary program?  How do you know?&lt;br /&gt;
# How important is each of the environment variables that is set by 3000userlogin?  Are these the only environment variables that are set after you successfully login?&lt;br /&gt;
# Note that 3000userlogin uses environ not envp (as an argument to main) to access environment variables.  Why not use envp?  (Try changing the code to use envp and see what happens.)&lt;br /&gt;
# What system calls is 3000userlogin using to change its uid and gid?  What arguments do they take, and how do they compare to those of the library wrappers that we are using?  (Note that you won&amp;#039;t be able to strace or run gdb as a regular user; instead, log in as root and run strace or gdb).&lt;br /&gt;
# Setup password-less login to your local system between the student and other account (or any two other accounts), following the above instructions.  Note that the &amp;quot;local&amp;quot; account is the one you are running the ssh command on.&lt;br /&gt;
# Setup password-less login to access.scs.carleton.ca, following the instructions above.&lt;br /&gt;
# Secure shell can be used to directly run a command on another program rather than the default shell.  For example, try &amp;quot;ssh student@localhost bc -l&amp;quot; and see that bc is run.  When you do this, does ssh directly run the specified command or does it first run a shell and have the shell run the command?  How can you verify what is happening?&lt;br /&gt;
# &amp;#039;&amp;#039;&amp;#039;(Optional):&amp;#039;&amp;#039;&amp;#039; Prompt for the user&amp;#039;s password before logging the user in.  To do this, you&amp;#039;ll need to get the right password hash and then figure out how to hash the entered password to check if it matches.  See online guides about [https://www.slashroot.in/how-are-passwords-stored-linux-understanding-hashing-shadow-utils how passwords are stored on Linux] for help.&lt;br /&gt;
&lt;br /&gt;
==Code==&lt;br /&gt;
&lt;br /&gt;
[https://homeostasis.scs.carleton.ca/~soma/os-2020w/code/tut4.tar.gz Download code for this tutorial (3000userlogin.c and Makefile)]&lt;br /&gt;
&lt;br /&gt;
===3000userlogin.c===&lt;br /&gt;
&lt;br /&gt;
[https://homeostasis.scs.carleton.ca/~soma/os-2020w/code/3000userlogin.c Download 3000userlogin.c]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot; line&amp;gt;&lt;br /&gt;
/* 3000userlogin.c */&lt;br /&gt;
/* version 0.1 */&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &amp;lt;sys/types.h&amp;gt;&lt;br /&gt;
#include &amp;lt;unistd.h&amp;gt;&lt;br /&gt;
#include &amp;lt;stdlib.h&amp;gt;&lt;br /&gt;
#include &amp;lt;pwd.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
int main(int argc, char *argv[])&lt;br /&gt;
{&lt;br /&gt;
        int result;&lt;br /&gt;
        char *shell_argv[3];&lt;br /&gt;
        char *username;&lt;br /&gt;
        extern char **environ;&lt;br /&gt;
        struct passwd *pw_entry;&lt;br /&gt;
                &lt;br /&gt;
        if (argc &amp;lt; 2) {&lt;br /&gt;
                fprintf(stderr, &amp;quot;Usage: %s &amp;lt;username&amp;gt;\n&amp;quot;, argv[0]);&lt;br /&gt;
                exit(-1);&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        printf(&amp;quot;uid=%d, euid=%d, gid=%d, egid=%d\n&amp;quot;,&lt;br /&gt;
               getuid(), geteuid(), getgid(), getegid());&lt;br /&gt;
&lt;br /&gt;
        username = argv[1];&lt;br /&gt;
        &lt;br /&gt;
        pw_entry = getpwnam(username);&lt;br /&gt;
        if (pw_entry == NULL) {&lt;br /&gt;
                fprintf(stderr, &amp;quot;Could not find user %s.\n&amp;quot;, username);&lt;br /&gt;
                exit(-2);&lt;br /&gt;
        }&lt;br /&gt;
                       &lt;br /&gt;
        result = setgid(pw_entry-&amp;gt;pw_gid);&lt;br /&gt;
        if (result != 0) {&lt;br /&gt;
                fprintf(stderr, &amp;quot;Failed to change to gid %d\n&amp;quot;,&lt;br /&gt;
                        pw_entry-&amp;gt;pw_gid);&lt;br /&gt;
                exit(-3);&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        result = setuid(pw_entry-&amp;gt;pw_uid);&lt;br /&gt;
        if (result != 0) {&lt;br /&gt;
                fprintf(stderr, &amp;quot;Failed to change to uid %d\n&amp;quot;,&lt;br /&gt;
                        pw_entry-&amp;gt;pw_uid);&lt;br /&gt;
                exit(-4);&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        result = chdir(pw_entry-&amp;gt;pw_dir);&lt;br /&gt;
        if (result != 0) {&lt;br /&gt;
                fprintf(stderr, &amp;quot;Failed to change to home dir %s\n&amp;quot;,&lt;br /&gt;
                        pw_entry-&amp;gt;pw_dir);&lt;br /&gt;
                exit(-5);&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        shell_argv[0] = &amp;quot;bash&amp;quot;;&lt;br /&gt;
        shell_argv[1] = &amp;quot;--login&amp;quot;;&lt;br /&gt;
        shell_argv[2] = NULL;&lt;br /&gt;
&lt;br /&gt;
        clearenv();&lt;br /&gt;
        setenv(&amp;quot;USERNAME&amp;quot;, pw_entry-&amp;gt;pw_name, 1);&lt;br /&gt;
        setenv(&amp;quot;PATH&amp;quot;, &amp;quot;/usr/bin:/bin&amp;quot;, 1);&lt;br /&gt;
        setenv(&amp;quot;SHELL&amp;quot;, &amp;quot;/bin/bash&amp;quot;, 1);&lt;br /&gt;
        setenv(&amp;quot;HOME&amp;quot;, pw_entry-&amp;gt;pw_dir, 1);&lt;br /&gt;
        setenv(&amp;quot;COMP3000&amp;quot;, &amp;quot;yes&amp;quot;, 1);&lt;br /&gt;
        &lt;br /&gt;
        execve(&amp;quot;/bin/bash&amp;quot;, shell_argv, environ);&lt;br /&gt;
     &lt;br /&gt;
        fprintf(stderr, &amp;quot;Failed to exec bash\n&amp;quot;);&lt;br /&gt;
        return -6;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Makefile===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;make&amp;quot; line&amp;gt;&lt;br /&gt;
.PHONY: setuid&lt;br /&gt;
&lt;br /&gt;
3000userlogin: 3000userlogin.c&lt;br /&gt;
	gcc -Wall -O 3000userlogin.c -o 3000userlogin&lt;br /&gt;
&lt;br /&gt;
setuid: 3000userlogin&lt;br /&gt;
	@echo &amp;quot;The following changes ownership to root, group to root, and sets the setuid bit on 3000userlogin:&amp;quot;&lt;br /&gt;
	sudo chown root:root 3000userlogin &amp;amp;&amp;amp; sudo chmod u+s 3000userlogin&lt;br /&gt;
	@echo &amp;quot;3000userlogin is now setuid root!&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Soma</name></author>
	</entry>
</feed>