{"id":539,"date":"2017-07-12T20:27:28","date_gmt":"2017-07-12T18:27:28","guid":{"rendered":"http:\/\/lisas.de\/~alex\/?p=237"},"modified":"2026-03-30T22:41:23","modified_gmt":"2026-03-30T20:41:23","slug":"sshd-on-lineageos-14-1","status":"publish","type":"post","link":"https:\/\/lisas.de\/luges\/index.php\/2017\/07\/12\/sshd-on-lineageos-14-1\/","title":{"rendered":"SSHD on LineageOS 14.1"},"content":{"rendered":"<p>As I&#8217;m currently switching phones I had to revisit the issue of how to get <strong><a href=\"https:\/\/en.wikipedia.org\/wiki\/OpenSSH\">sshd<\/a><\/strong> running on a pristine <a href=\"https:\/\/lineageos.org\/\">LineageOS<\/a> install. I decided to collect the steps here as the how-to formerly available on the CM wiki has vanished together with CM itself. Note that some\u00a0 steps are not incredibly detailed and you really should be <strong>aware of the security implications<\/strong> before going ahead with this.<span id=\"more-237\"><\/span><\/p>\n<h2>Prerequisites<\/h2>\n<ul>\n<li>a device with <a href=\"http:\/\/download.lineageos.org\/\">a current LineageOS 14.1 build<\/a> installed<\/li>\n<li><a href=\"https:\/\/wiki.lineageos.org\/adb_fastboot_guide.html\">USB debugging enabled<\/a><\/li>\n<li>root access (preferably by installing <a href=\"https:\/\/download.lineageos.org\/extras\">the official SU addon<\/a>)<\/li>\n<li>if you want <strong>sshd<\/strong> to run automatically after boot, you have to be willing to install <a href=\"http:\/\/lisas.de\/~alex\/?p=209\">my little <strong>RunUserInit<\/strong> hack<\/a> and allow it to acquire root privileges<\/li>\n<\/ul>\n<h2>Configuring SSHD<\/h2>\n<p>While LineageOS includes all necessary software, the configuration of <strong>sshd<\/strong> must be completed manually:<\/p>\n<ol>\n<li>Connect the device via USB<\/li>\n<li>Run <strong>adb<\/strong> with root privileges:<br \/> <code>adb root<\/code><\/li>\n<li>Upload your public ssh key to the device:<br \/> <code>adb push ~\/.ssh\/id_rsa.pub \/data\/ssh\/authorized_keys<\/code><\/li>\n<li>Now, open a root shell and switch to <strong>bash<\/strong> to get <strong>vim<\/strong> to behave nicely on the device through <strong>adb<\/strong>:<br \/> <code>adb shell<\/code><br \/> <code>bash<\/code><\/li>\n<li>Use <strong>cat<\/strong> or <strong>vim<\/strong> to make the following fragment the contents of <strong>\/data\/ssh\/sshd_config<\/strong>:<br \/> <br \/>\n<blockquote>\n<p>AuthorizedKeysFile \/data\/ssh\/authorized_keys<br \/> ChallengeResponseAuthentication no<br \/> PasswordAuthentication no<br \/> PermitRootLogin no<br \/> Subsystem sftp internal-sftp<br \/> pidfile \/data\/ssh\/sshd.pid<\/p>\n<\/blockquote>\n<\/li>\n<li>Place a modified version of the start script in the <strong>userinit.d<\/strong> directory:<br \/> <code>mkdir \/data\/local\/userinit.d<\/code><br \/> <code>sed 's#\/system\/etc\/ssh#\/data\/ssh#' \/system\/bin\/start-ssh <\/code><br \/> <code>\u00a0\u00a0\u00a0\u00a0\u00a0 &gt; \/data\/local\/userinit.d\/99sshd<\/code><\/li>\n<li>Now correct the file privileges:<br \/> <code>chmod 755 \/data\/local\/userinit.d\/99sshd<\/code><br \/> <code>chmod 600 \/data\/ssh\/authorized_keys<\/code><br \/> <code>chown shell \/data\/ssh\/authorized_keys<\/code><br \/> <code>chmod 644 \/data\/ssh\/sshd_config<\/code><\/li>\n<\/ol>\n<h2>Running SSHD<\/h2>\n<p>Now you should be able to run<strong> sshd<\/strong> manually by executing<br \/> <code>\/data\/local\/userinit.d\/99sshd<\/code><br \/> If so you can log on as user <em>shell<\/em> to the device using your ssh key. See my <a href=\"http:\/\/lisas.de\/~alex\/?p=209\">previous post <\/a>to find out how you can make sure <strong>sshd<\/strong> is started whenever the device is booted.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>As I&#8217;m currently switching phones I had to revisit the issue of how to get sshd running on a pristine LineageOS install. I decided to collect the steps here as the how-to formerly available on the CM wiki has vanished together with CM itself. Note that some\u00a0 steps are not incredibly detailed and you really [&hellip;]<\/p>\n","protected":false},"author":0,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-539","post","type-post","status-publish","format-standard","hentry","category-luges"],"_links":{"self":[{"href":"https:\/\/lisas.de\/luges\/index.php\/wp-json\/wp\/v2\/posts\/539","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lisas.de\/luges\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lisas.de\/luges\/index.php\/wp-json\/wp\/v2\/types\/post"}],"replies":[{"embeddable":true,"href":"https:\/\/lisas.de\/luges\/index.php\/wp-json\/wp\/v2\/comments?post=539"}],"version-history":[{"count":4,"href":"https:\/\/lisas.de\/luges\/index.php\/wp-json\/wp\/v2\/posts\/539\/revisions"}],"predecessor-version":[{"id":1349,"href":"https:\/\/lisas.de\/luges\/index.php\/wp-json\/wp\/v2\/posts\/539\/revisions\/1349"}],"wp:attachment":[{"href":"https:\/\/lisas.de\/luges\/index.php\/wp-json\/wp\/v2\/media?parent=539"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lisas.de\/luges\/index.php\/wp-json\/wp\/v2\/categories?post=539"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lisas.de\/luges\/index.php\/wp-json\/wp\/v2\/tags?post=539"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}