<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Ultraxime</title>
	<atom:link href="https://www.ultraxime.fr/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.ultraxime.fr</link>
	<description>Compilation of tutorials for system administrator </description>
	<lastBuildDate>Wed, 04 Dec 2024 00:30:00 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.7.2</generator>
	<item>
		<title>User and Group: What for and How to create them</title>
		<link>https://www.ultraxime.fr/user-and-group-what-for-and-how-to-create-them/</link>
					<comments>https://www.ultraxime.fr/user-and-group-what-for-and-how-to-create-them/#respond</comments>
		
		<dc:creator><![CDATA[ultraxime]]></dc:creator>
		<pubDate>Wed, 04 Dec 2024 00:24:55 +0000</pubDate>
				<category><![CDATA[Users and Groups]]></category>
		<category><![CDATA[Group]]></category>
		<category><![CDATA[User]]></category>
		<guid isPermaLink="false">https://www.ultraxime.fr/?p=60</guid>

					<description><![CDATA[Users What is it A server (and to some extent a computer) is usually shared between several people. But how could we do that? One solution to allow several people access to a server is sharing the same credentials. But this comes with many issues: The solution offered by Linux is the users.That way every&#8230; <a class="more-link" href="https://www.ultraxime.fr/user-and-group-what-for-and-how-to-create-them/">Continue reading <span class="screen-reader-text">User and Group: What for and How to create them</span></a>]]></description>
										<content:encoded><![CDATA[


<h2 class="wp-block-heading" id="users">Users</h2>



<h3 class="wp-block-heading">What is it</h3>



<p>A server (and to some extent a computer) is usually shared between several people. But how could we do that?</p>



<p>One solution to allow several people access to a server is sharing the same credentials. But this comes with many issues:</p>



<ul class="wp-block-list">
<li>Everyone can modify the files of others</li>



<li>Everyone can see the files of everyone, for example, an employee could look at files from HR and get the address of all the employees</li>



<li>Generally, everyone can do everything, like shutting down the server or destroying the databases. And no one would know who did it at it would have been root.</li>
</ul>



<p>The solution offered by Linux is the users.<br>That way every person who needs to access the server corresponds to a user. Each user has their username, password, and several other information.</p>



<p>The default user on a computer is <code>root</code>. This user is the main administrator, it can perform everything on the computer, even erase the hard drive (<code>rm -rf /</code>).<br>For security reasons, this user should never be used as the main user.<br>That is why we are going to see how to create a user.</p>



<h3 class="wp-block-heading">How to create a normal user</h3>



<p>Creating a user depends on the distribution of Linux you are using</p>



<h4 class="wp-block-heading">Ubuntu</h4>



<p>Ubuntu provides an easy-to-use tool to create a user, <code>adduser</code>.</p>



<p>To create the user <code>test</code> the command is the following.</p>



<pre class="wp-block-code"><code lang="bash" class="language-bash">sudo adduser test</code></pre>



<p>You will then be prompted several questions to answer.</p>



<ul class="wp-block-list">
<li>The password, you have to choose a password.<br>It cannot be an empty password.<br>You can generate a random password using <code>pwgen</code>. We will cover more about passwords in another tutorial.</li>



<li>The full name of the user: it can be empty.<br>But is useful to easily differentiate between users.</li>



<li>The room number of the user: it can be empty</li>



<li>The work phone of the user: it can be empty</li>



<li>The home phone of the user: it can be empty</li>



<li>Other information about the user: it can be empty</li>
</ul>



<h5 class="wp-block-heading">Option for normal user</h5>



<p>Several options can be used when creating a user. <br>Here is a short sample:</p>



<ul class="wp-block-list">
<li><code>--disabled-login</code><br>Do not set the password. It will prevent the user from being able to log in before a password is set for the user.</li>



<li><code>--disabled-password</code><br>Similar to the previous one, but still allows connection without a password, for example, SSH with keys.</li>



<li><code>--home &lt;dir></code><br>Specify the home directory of the user. If not specified the default one is created, usually <code>/home/&lt;username></code></li>



<li><code>--no-create-home</code><br>Do not create the home directory. Useful for users who can log in but will never save data on the server.</li>



<li><code>--shell &lt;bin></code><br>Specify the default shell of the user.</li>
</ul>



<h3 class="wp-block-heading">System User</h3>



<p>The file <code>/etc/passwd</code> contains the list of all users on the server.<br>And if you look at yours you will see many more than just the one you created. Why would you ask?<br>They are system users.</p>



<p>Many software needs to run tasks in the background that are not run by a specific person. For example, your web server needs to serve the requests but each request does not necessarily correspond to one of the employees. So with which user should the software run?</p>



<p>The Linux solution was to create what is called system users. They are users who do not correspond to real people but rather to a specific software or service.<br>For example, the system user for your web server is usually called <code>www-data</code>.</p>



<p>As these system users do not correspond to real people, they do not have personal information or a home directory. Usually, they can not even log in.</p>



<p>Creating a system user can sometimes be useful for example for crontab or other things. This is done with the option <code>--system</code>, like the following command.</p>



<pre class="wp-block-code"><code lang="bash" class="language-bash">sudo adduser --system test</code></pre>



<h2 class="wp-block-heading">Groups</h2>



<h3 class="wp-block-heading">What is it</h3>



<p>We saw in the <a href="#users">previous section</a> that we can manage the right on a user basis. <br>But do we need to configure the right for all the members of a team or how can several people share the ownership of files?</p>



<p>To do so, Linux uses what is called groups. This way we can share rights across several users without configuring every user separately. </p>



<p>A user always has a main group, usually named after him, and additional groups.</p>



<p>While the names of standard groups can vary, here are some of them:</p>



<ul class="wp-block-list">
<li><code>adm</code>: the group of system administrators</li>



<li><code>sudo</code>: the group of users allowed to sudo as root</li>



<li><code>docker</code>: the group of users allowed to run docker commands</li>



<li><code>wireshark</code>: the group of users allowed to use Wireshark and as such listen to network traffic</li>



<li><code>www-data</code>: the default group of the web server, useful for web dev to be able to edit the file of the web server without messing with the right of the web server</li>
</ul>



<h3 class="wp-block-heading">Adding a group to a user</h3>



<p>Now that we have identified which groups are relevant to add to our users, how do we do it?<br>We are going to modify them with the command <code>usermod</code>.</p>



<p>For example, to add the <code>sudo</code> group to the test user, we use the following command.</p>



<pre class="wp-block-code"><code lang="bash" class="language-bash">sudo usermode test -aG sudo</code></pre>



<h3 class="wp-block-heading">Creating a group</h3>



<p>Sometimes it can be interesting to create a group, for example, for a specific team, to allow them to share folders.<br>To do so, we use the command <code>addgroup</code> as in the following.</p>



<pre class="wp-block-code"><code lang="bash" class="language-bash">sudo addgroup &lt;team></code></pre>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<p>This tutorial is mainly inspired by <a href="https://manpages.debian.org/bookworm/adduser/adduser.8.en.html" target="_blank" rel="noopener">the man page of <code>adduser</code> and <code>addgroup</code></a></p>



<p></p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.ultraxime.fr/user-and-group-what-for-and-how-to-create-them/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>How to create an SSH Key</title>
		<link>https://www.ultraxime.fr/creating-an-ssh-key/</link>
					<comments>https://www.ultraxime.fr/creating-an-ssh-key/#respond</comments>
		
		<dc:creator><![CDATA[ultraxime]]></dc:creator>
		<pubDate>Wed, 27 Nov 2024 22:14:11 +0000</pubDate>
				<category><![CDATA[SSH]]></category>
		<category><![CDATA[SSH Key]]></category>
		<guid isPermaLink="false">https://www.ultraxime.fr/?p=7</guid>

					<description><![CDATA[What is an SSH Key Why is it useful An SSH Key is a means to secure the authentication to an SSH server.It allows a more robust connection to the server compared to password authentication. We will see in another tutorial how to set up this authentication on a server. When authenticating to a server&#8230; <a class="more-link" href="https://www.ultraxime.fr/creating-an-ssh-key/">Continue reading <span class="screen-reader-text">How to create an SSH Key</span></a>]]></description>
										<content:encoded><![CDATA[


<h2 class="wp-block-heading">What is an SSH Key</h2>



<h3 class="wp-block-heading">Why is it useful</h3>



<p>An SSH Key is a means to secure the authentication to an SSH server.<br>It allows a more robust connection to the server compared to password authentication. We will see in another tutorial how to set up this authentication on a server.</p>



<p>When authenticating to a server with your SSH key, your client will choose a key that is recognized by the server and then ask you the passphrase for this key. This passphrase will be used only by your computer to decipher your private key in order to prove to the server that you are who you say you are.</p>



<p>Example of use:</p>



<ul class="wp-block-list">
<li>SSH Server<br>Most SSH servers are configured to accept SSH Keys as a means of connection and many of them only accept this means of connection.<br>It is more secure and easier to use for the user. Many operating systems carry an SSH Agent (software that stores unlocked SSH Keys) which prevents having to type every times the passphrase to the key; making the connections look instantaneous without user input</li>



<li>Git server<br>For example, GitHub, GitLab, and GitTea use SSH connection to perform remote actions on Git repositories, such as fetching, pushing, cloning, &#8230;<br>Using an SSH connection allows easier use of git; you do not need to authenticate every time using your username and your password.</li>
</ul>



<h3 class="wp-block-heading">What is it </h3>



<p>An SSH Key is composed of two files/keys:</p>



<ul class="wp-block-list">
<li>The private key: it is usually named <code>id_&lt;something&gt;</code>.<br>This file is, most of the time, protected by a passphrase, it should never be shared, copied, or moved.<br>As its name suggests, it is private, it is the part of the key that proves you own the key. If someone were to acquire this file and break its passphrase it could impersonate you for the service that recognizes this key.</li>



<li>The Public Key: it is usually named like the private key but ends with a <code>.pub</code>.<br>This file can be shared with anyone you want to identify you; for example an SSH server, <a href="https://github.com" target="_blank" rel="noopener">GitHub</a>, <a href="https://gitlab.com" target="_blank" rel="noopener">GitLab</a>, &#8230;</li>
</ul>



<p>These files are most of the time stored in a folder name <code>.ssh</code> in your home. For example on Linux, the folder is <code>$HOME/.ssh</code></p>



<h3 class="wp-block-heading">How does it work</h3>



<p>The working principle of the SSH Key:</p>



<ol class="wp-block-list">
<li>Your computer will look at available SSH Keys in specific folders, usually <code>.ssh</code></li>



<li>It will propose some keys to the SSH Server</li>



<li>If one of the keys is recognized by the server, the server will offer to continue the authentication using this key</li>



<li>The server then generates a message, cipher it with the public key, and sends it to you</li>



<li>Your client then deciphers it using your private key (that is the moment when it asks for the passphrase) and sends back the deciphered message to the server</li>



<li>If the message is the correct one, the server recognizes you as the rightful person and connects you</li>
</ol>



<p>This works because something ciphered with the public key can only be deciphered using the private key. Using any other method would be too hard. With keys strong enough, the current best computer (and the one in the foreseeable future) would take longer than the age of the Univers to decypher it without the private key.</p>



<h2 class="wp-block-heading">Creating an SSH Key</h2>



<p>In this post, we are going to cover how to create an SSH Key.<br>This is aimed to be used on Linux but should be working on Windows and MacOS</p>



<p>To create the key, we are going to use the <code>ssh-keygen</code> utility.<br>It should already be installed on your computer. If this is not the case, you can install it by installing <code>openssh-client</code> or <code>openssh-clients</code> depending on your distribution.</p>



<h3 class="wp-block-heading">Choosing the key type</h3>



<p>Several types of keys are available. The main two are the following.</p>



<ul class="wp-block-list">
<li>RSA Keys: RSA is a rather old protocol (1977) based on the factoring of large prime numbers.<sup data-fn="89b45cb7-0bb3-4433-a385-0e9f7a392aa0" class="fn"><a href="#89b45cb7-0bb3-4433-a385-0e9f7a392aa0" id="89b45cb7-0bb3-4433-a385-0e9f7a392aa0-link">1</a></sup><br>While still being pretty robust, it needs rather big keys to offer satisfactory security.</li>



<li>ED25519 Keys: ED25519 is a newer protocol (2011) based on EdDSA using elliptic curves.<sup data-fn="adc1fca5-e58d-4511-9ca9-4e412eec423a" class="fn"><a id="adc1fca5-e58d-4511-9ca9-4e412eec423a-link" href="#adc1fca5-e58d-4511-9ca9-4e412eec423a">2</a></sup><br>It is faster and requires smaller keys to have the same security as RSA. But being newer, some old systems may not support it.</li>
</ul>



<p>Some other schemes exist (DSA, ECDSA) but are not relevant here, DSA is obsolete and ECDSA is harder to configure while offering similar security.</p>



<h3 class="wp-block-heading">Choosing the key length</h3>



<ul class="wp-block-list">
<li>RSA Keys: I recommend using a key of 4096 bits, as it is currently the longest available.<br>Under 2048 bits the key cannot be considered secure.<br>The default length is 3072 bits and is considered sufficient.</li>



<li>ED25519: These keys have a fixed length (256 bits), so we do not need to choose.</li>
</ul>



<h3 class="wp-block-heading">Create the key</h3>



<p>Now that we know what to take into account to create a key, we are going to create one.</p>



<p>Using the following command create the default ED25519 key.</p>



<pre class="wp-block-code has-medium-font-size"><code lang="bash" class="language-bash">ssh-keygen -t ed25519</code></pre>



<p>To create the default RSA key of 4096 bits, we would use the command :</p>



<pre class="wp-block-code"><code lang="bash" class="language-bash">ssh-keygen -t rsa -b 4096</code></pre>



<h3 class="wp-block-heading">To go further</h3>



<h4 class="wp-block-heading">Adding a comment</h4>



<p>By default, the comment of the created key is <code>&lt;username&gt;@&lt;computer&gt;</code>.<br>You can change this to be anything, for example, a message about the use of the key.</p>



<p>This is done with the option <code>-C</code>:</p>



<pre class="wp-block-code"><code lang="bash" class="language-bash">ssh-keygen -C "Comment"</code></pre>



<h4 class="wp-block-heading">Specifying the password</h4>



<p>By default, you will be prompted to enter the passphrase, but you can specify it directly in the command, using the option <code>-N</code>:</p>



<pre class="wp-block-code"><code lang="bash" class="language-bash">ssh-keygen -N "&lt;passphrase&gt;"</code></pre>



<h4 class="wp-block-heading">Specifying the file </h4>



<p>By default, you will be prompted to set the path and filename to store the key, usually <code>~/.ssh/id_&lt;type&gt;</code>.<br>You can change this behavior by specifying the path with the option <code>-f</code>:</p>



<pre class="wp-block-code"><code lang="bash" class="language-bash">ssh-keygen -f "$HOME/.ssh/id_git"</code></pre>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<p>This tutorial is mainly inspired by <a href="https://man7.org/linux/man-pages/man1/ssh-keygen.1.html" target="_blank" rel="noopener">the man page of <code>ssh-keygen</code></a></p>


<ol class="wp-block-footnotes"><li id="89b45cb7-0bb3-4433-a385-0e9f7a392aa0"><a href="https://en.wikipedia.org/wiki/RSA_(cryptosystem)" target="_blank" rel="noopener">https://en.wikipedia.org/wiki/RSA_(cryptosystem)</a> <a href="#89b45cb7-0bb3-4433-a385-0e9f7a392aa0-link" aria-label="Jump to footnote reference 1"><img src="https://s.w.org/images/core/emoji/15.0.3/72x72/21a9.png" alt="↩" class="wp-smiley" style="height: 1em; max-height: 1em;" />︎</a></li><li id="adc1fca5-e58d-4511-9ca9-4e412eec423a"><a href="https://en.wikipedia.org/wiki/EdDSA#Ed25519" data-type="link" data-id="https://en.wikipedia.org/wiki/EdDSA#Ed25519" target="_blank" rel="noopener">https://en.wikipedia.org/wiki/EdDSA#Ed25519</a> <a href="#adc1fca5-e58d-4511-9ca9-4e412eec423a-link" aria-label="Jump to footnote reference 2"><img src="https://s.w.org/images/core/emoji/15.0.3/72x72/21a9.png" alt="↩" class="wp-smiley" style="height: 1em; max-height: 1em;" />︎</a></li></ol>


<p></p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.ultraxime.fr/creating-an-ssh-key/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
