{"id":315,"date":"2022-01-30T21:02:00","date_gmt":"2022-01-30T19:02:00","guid":{"rendered":"https:\/\/www.tobanet.de\/s\/?p=315"},"modified":"2022-02-10T16:57:51","modified_gmt":"2022-02-10T14:57:51","slug":"sweet-home-setup-sudo-ssh-and-dotfiles","status":"publish","type":"post","link":"https:\/\/www.tobanet.de\/s\/2022\/01\/sweet-home-setup-sudo-ssh-and-dotfiles\/","title":{"rendered":"Sweet Home &#8211; setup sudo, ssh and dotfiles"},"content":{"rendered":"\n<p>When I build a new Linux host\/Raspberry to play around, there are four basic things I always do first. No fancy automation, just quick and dirty manual labor:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>install my favorite editor vim, make vim the default editor (optional)<\/li><li>add my ssh-key to authorized_keys for passwordless logins via SSH<\/li><li>configure sudo to avoid the password prompt when doing superuser stuff<\/li><li>clone my dotfiles git repo to setup my environment for convenient terminal usage<\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"vim\">vim<\/h2>\n\n\n\n<p>Without vim I am lost.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># accept to enter the password for sudo once more:\nsudo apt-get install vim\n\n# make vim the default editor (optional)\nsudo update-alternatives --set editor \/usr\/bin\/vim.basic<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"ssh-key\">ssh-key<\/h2>\n\n\n\n<p>I usually login with my password to accomplish the task. If there is a default password I change it.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cd ~\nmkdir .ssh\ntouch .ssh\/authorized_keys &amp;&amp; chmod 640 .ssh\/authorized_keys\n# copy + paste id.pub &gt; .ssh\/authorized_keys\n# I do this with vim, any editor will do ;-)\nvim .ssh\/authorized_keys<\/code><\/pre>\n\n\n\n<p>Make sure your ssh-key is loaded (e.g. with putty pageant) and login to verify it works.<\/p>\n\n\n\n<p>Now I disable logins with passwords via SSH.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo vim \/etc\/ssh\/sshd_config\n\n# make sure there is a line with\nPasswordAuthentication no\n\n# restart ssh\nsudo systemctl restart ssh<\/code><\/pre>\n\n\n\n<p>Do not logout. Check if everything works as expected first. This way your SSH session remains available to fix things if necessary.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"sudo\">sudo<\/h2>\n\n\n\n<p>On my hosts I want to  use sudo without password prompts.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo visudo\n\n# add the following line, replace 'username' with your login:\nusername ALL=(ALL) NOPASSWD: ALL<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"dotfiles\">dotfiles<\/h2>\n\n\n\n<p>This is where the magic comes in \ud83d\ude09<\/p>\n\n\n\n<p>Managing your dotfiles with git is quite a popular topic for Mac and Linux users. You will find a lot of resources out there. A helpful starting point is <a rel=\"noreferrer noopener\" href=\"https:\/\/dotfiles.github.io\/\" target=\"_blank\">https:\/\/dotfiles.github.io\/<\/a> or <a rel=\"noreferrer noopener\" href=\"https:\/\/github.com\/webpro\/awesome-dotfiles\" target=\"_blank\">https:\/\/github.com\/webpro\/awesome-dotfiles<\/a><\/p>\n\n\n\n<p>When I started to organize my personal dotfiles I based my <a rel=\"noreferrer noopener\" href=\"https:\/\/github.com\/tbaecker\/dotfiles\" target=\"_blank\">repository<\/a> on the <a rel=\"noreferrer noopener\" href=\"https:\/\/github.com\/holman\/dotfiles\" target=\"_blank\">work of Zach Holman<\/a>. <\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"what-are-dotfiles-good-for\">What are dotfiles good for?<\/h3>\n\n\n\n<p>In Unix-like systems files and directories starting with a dot in its name are &#8220;hidden&#8221; and don&#8217;t show by default. That is where the name comes from. Dotfiles store per-user configuration for applications like bash, git, vim and many others.<\/p>\n\n\n\n<p>I prefer to have a consistent configuration across my hosts for the fundamental tools I mentioned above. <\/p>\n\n\n\n<p>Make them rock. Just clone the repo and initialize the environment:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># install git first\nsudo apt-get install git\n\ngit clone https:\/\/github.com\/tbaecker\/dotfiles.git ~\/.dotfiles\n~\/.dotfiles\/bin\/dotfiles<\/code><\/pre>\n\n\n\n<p>Log out and in again. You&#8217;re setup.<\/p>\n\n\n\n<p>Dotfiles are a very personal thing. You tweak them the way you want. Check out the various approaches and setups and choose one that fits your expectations. You will have to take some time but once setup it will begin to pay off.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>When I build a new Linux host\/Raspberry to play around, there are four basic things I always do first. No fancy automation, just quick and dirty manual labor: install my favorite editor vim, make vim the default editor (optional) add my ssh-key to authorized_keys for passwordless logins via SSH configure sudo to avoid the password prompt when doing superuser stuff clone my dotfiles git repo to setup my environment for convenient terminal usage vim Without vim I am lost. ssh-key&#8230;<\/p>\n<p class=\"read-more\"><a class=\"btn btn-default\" href=\"https:\/\/www.tobanet.de\/s\/2022\/01\/sweet-home-setup-sudo-ssh-and-dotfiles\/\"> Read More<span class=\"screen-reader-text\">  Read More<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[],"class_list":["post-315","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/www.tobanet.de\/s\/wp-json\/wp\/v2\/posts\/315","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.tobanet.de\/s\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tobanet.de\/s\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tobanet.de\/s\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tobanet.de\/s\/wp-json\/wp\/v2\/comments?post=315"}],"version-history":[{"count":2,"href":"https:\/\/www.tobanet.de\/s\/wp-json\/wp\/v2\/posts\/315\/revisions"}],"predecessor-version":[{"id":323,"href":"https:\/\/www.tobanet.de\/s\/wp-json\/wp\/v2\/posts\/315\/revisions\/323"}],"wp:attachment":[{"href":"https:\/\/www.tobanet.de\/s\/wp-json\/wp\/v2\/media?parent=315"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tobanet.de\/s\/wp-json\/wp\/v2\/categories?post=315"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tobanet.de\/s\/wp-json\/wp\/v2\/tags?post=315"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}