{"id":453,"date":"2023-09-07T11:48:03","date_gmt":"2023-09-07T11:48:03","guid":{"rendered":"https:\/\/blog.nibelheim.fr\/?p=453"},"modified":"2023-09-07T11:49:17","modified_gmt":"2023-09-07T11:49:17","slug":"ajouter-un-utilisateur-ssh-avec-sa-paire-de-cles-ssh","status":"publish","type":"post","link":"https:\/\/blog.nibelheim.fr\/?p=453","title":{"rendered":"Ajouter un utilisateur (SSH) avec sa paire de cl\u00e9s SSH"},"content":{"rendered":"\n<p>Nous allons voir ici comment ajouter et g\u00e9rer un nouvel utilisateur sur votre Raspberry Pi tout en g\u00e9rant son authentification via paire de cl\u00e9s SSH.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Cr\u00e9ation de la paire de cl\u00e9s SSH<\/h4>\n\n\n\n<p>Je vous invite \u00e0 vous r\u00e9f\u00e9re<a href=\"https:\/\/blog.nibelheim.fr\/?p=380\" data-type=\"link\" data-id=\"https:\/\/blog.nibelheim.fr\/?p=380\">r \u00e0 la partie 1 de mon pr\u00e9c\u00e9dent tuto<\/a>.<br>Nous allons partir du principe que les cl\u00e9s seront nomm\u00e9es <strong>key<\/strong> <em>(cl\u00e9 priv\u00e9e<\/em>) et <strong>key.pub<\/strong> <em>(cl\u00e9 publique)<\/em>, et plac\u00e9es dans <strong>\/home\/user<\/strong>. <em>(notre utilisateur courant, qui a les droits administrateur)<\/em>.<br>Ce seront \u00e9videmment les cl\u00e9s que notre <strong>nouvel <\/strong>utilisateur utilisera pour s&#8217;identifier.<br>La cl\u00e9 <strong>key <\/strong>(cl\u00e9 priv\u00e9e, donc) devra \u00eatre fournie au nouvel utilisateur <em>(et d\u00e9brouillez-vous pour le faire. De rien.)<\/em>.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Cr\u00e9ation du nouvel utilisateur<\/h4>\n\n\n\n<p>Depuis votre Pi, avec un compte acc\u00e8s root :<\/p>\n\n\n\n<pre class=\"wp-block-code has-tertiary-background-color has-background\"><code>sudo adduser <strong><em>nouvel_utilisateur    <\/em><\/strong><em>#Ne pas oublier de sp\u00e9cifier un mot de passe!<\/em>\nsudo groupadd <strong><em>nouvel_utilisateur    <\/em><\/strong><em>#Histoire d'avoir son groupe \u00e0 lui (il a le m\u00eame nom, s'normal)<\/em>\nsudo usermod -aG <strong><em>nouvel_utilisateur nouvel_utilisateur    <\/em><\/strong><em>#Ajout au nouveau groupe<\/em>\nsudo mkdir \/home\/<strong><em>nouvel_utilisateur<\/em><\/strong>\/.ssh\nsudo chmod 0700 \/home\/<em><strong>nouvel_utilisateur<\/strong><\/em>\/.ssh\nsudo cp ~\/key.pub \/home\/<em><strong>nouvel_utilisateur<\/strong><\/em>\/.ssh\/authorized_keys\nsudo chmod 0600 \/home\/<em><strong>nouvel_utilisateur<\/strong><\/em>\/.ssh\/authorized_keys\nsudo chown <em><strong>nouvel_utilisateur<\/strong><\/em> \/home\/<strong><em>nouvel_utilisateur <\/em><\/strong>-R<\/code><\/pre>\n\n\n\n<p>Ceci fait, il faut rajouter l&#8217;utilisateur \u00e0 ceux autoris\u00e9s \u00e0 se connecter en SSH :<\/p>\n\n\n\n<pre class=\"wp-block-code has-tertiary-background-color has-background\"><code>sudo nano \/etc\/ssh\/sshd_config<\/code><\/pre>\n\n\n\n<p>Puis ajoutez apr\u00e8s votre utilisateur le nom du nouveau, s\u00e9par\u00e9 par un espace, du genre :<\/p>\n\n\n\n<pre class=\"wp-block-code has-tertiary-background-color has-background\"><code>AllowUsers User <strong><em>nouvel_utilisateur <\/em><\/strong><\/code><\/pre>\n\n\n\n<p>Ceci fait, n&#8217;oubliez pas de faire :<\/p>\n\n\n\n<pre class=\"wp-block-code has-tertiary-background-color has-background\"><code>sudo service ssh restart<\/code><\/pre>\n\n\n\n<p>Et vous voil\u00e0 rendu \ud83d\ude42<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Nous allons voir ici comment ajouter et g\u00e9rer un nouvel utilisateur sur votre Raspberry Pi tout en g\u00e9rant son authentification via paire de cl\u00e9s SSH. Cr\u00e9ation de la paire de cl\u00e9s SSH Je vous invite \u00e0 vous r\u00e9f\u00e9rer \u00e0 la partie 1 de mon pr\u00e9c\u00e9dent tuto.Nous allons partir du principe [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,8],"tags":[],"class_list":["post-453","post","type-post","status-publish","format-standard","hentry","category-linux","category-raspberry-pi"],"_links":{"self":[{"href":"https:\/\/blog.nibelheim.fr\/index.php?rest_route=\/wp\/v2\/posts\/453","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.nibelheim.fr\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.nibelheim.fr\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.nibelheim.fr\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.nibelheim.fr\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=453"}],"version-history":[{"count":5,"href":"https:\/\/blog.nibelheim.fr\/index.php?rest_route=\/wp\/v2\/posts\/453\/revisions"}],"predecessor-version":[{"id":466,"href":"https:\/\/blog.nibelheim.fr\/index.php?rest_route=\/wp\/v2\/posts\/453\/revisions\/466"}],"wp:attachment":[{"href":"https:\/\/blog.nibelheim.fr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=453"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.nibelheim.fr\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=453"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.nibelheim.fr\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=453"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}