{"id":46,"date":"2016-03-28T17:11:20","date_gmt":"2016-03-28T16:11:20","guid":{"rendered":"http:\/\/eoghan.me.uk\/notes\/?p=46"},"modified":"2016-05-07T22:56:58","modified_gmt":"2016-05-07T21:56:58","slug":"sftp-public-key-auth","status":"publish","type":"post","link":"https:\/\/eoghan.me.uk\/notes\/2016\/03\/28\/sftp-public-key-auth\/","title":{"rendered":"Setting up Public Key Authentication for RPi SFTP"},"content":{"rendered":"<p>To make a Python script on my Raspberry Pi easily upload files to a Secure FTP server, I used the steps from Computer Hope&#8217;s <a href=\"http:\/\/www.computerhope.com\/unix\/sftp.htm#Public-Key-Authentication\">Linux and UNIX sftp command<\/a> page to set up Public Key Authentication.<\/p>\n<p>Because my script uses the GPIO pins, it needs to be run as root (&#8216;sudo python photobooth.py&#8217;), and so the public and private keys needed to be stored in the root user&#8217;s ~\/.ssh directory (root@raspberrypi:~\/.ssh), not the normal &#8216;pi&#8217; user&#8217;s ~\/.ssh directory.<br \/>\n<!--more--><br \/>\nSo after completing Computer Hope&#8217;s steps to create the public and private keys in my RPi&#8217;s normal &#8216;pi&#8217; user&#8217;s .ssh directory, I switched to &#8216;root&#8217; user, and copied the .ssh directory from &#8216;pi&#8217; user&#8217;s home directory to the &#8216;root&#8217; user&#8217;s home directory:<\/p>\n<pre class=\"lang:sh decode:true \" >sudo -i\r\ncp -r \/home\/pi\/.ssh ~\/.ssh\r\nexit\r\n<\/pre>\n<h2>Uploading public key to server<\/h2>\n<p>My server has a cPanel interface, so I copied the public key to the server by:<\/p>\n<ol>\n<li>Log into cPanel.<\/li>\n<li>Visit the &#8216;SSH Access&#8217; page.<\/li>\n<li>Visit the &#8216;Manage SSH Keys&#8217; page.<\/li>\n<li>Choose to &#8216;Import Key&#8217;.<\/li>\n<li>Fill in the form:\n<ol>\n<li>Name for this key: &#8216;id_rsa&#8217;.<\/li>\n<li>Paste the public key &#8230;: pasted in the contents of the &#8216;id_rsa.pub&#8217; file in my RPi root&#8217;s .ssh directory.<\/li>\n<\/ol>\n<\/li>\n<li>Click &#8216;Import&#8217;<\/li>\n<li>Then in the Public Keys table, authorise the key with:\n<ol>\n<li>Click the &#8216;Manage&#8217; link along side my new public key.<\/li>\n<li>Click &#8216;Authorize&#8217;<\/li>\n<\/ol>\n<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>To make a Python script on my Raspberry Pi easily upload files to a Secure FTP server, I used the steps from Computer Hope&#8217;s Linux and UNIX sftp command page to set up Public Key Authentication. Because my script uses the GPIO pins, it needs to be run as root (&#8216;sudo python photobooth.py&#8217;), and so [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[],"class_list":["post-46","post","type-post","status-publish","format-standard","hentry","category-raspberry-pi"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.2 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Setting up Public Key Authentication for RPi SFTP - Eoghan&#039;s Notes<\/title>\n<meta name=\"description\" content=\"Setting up Public Key Authentication to upload files to a Secure FTP server using a Python script.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/eoghan.me.uk\/notes\/2016\/03\/28\/sftp-public-key-auth\/\" \/>\n<meta property=\"og:locale\" content=\"en_GB\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Setting up Public Key Authentication for RPi SFTP - Eoghan&#039;s Notes\" \/>\n<meta property=\"og:description\" content=\"Setting up Public Key Authentication to upload files to a Secure FTP server using a Python script.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/eoghan.me.uk\/notes\/2016\/03\/28\/sftp-public-key-auth\/\" \/>\n<meta property=\"og:site_name\" content=\"Eoghan&#039;s Notes\" \/>\n<meta property=\"article:published_time\" content=\"2016-03-28T16:11:20+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2016-05-07T21:56:58+00:00\" \/>\n<meta name=\"author\" content=\"Eoghan\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Eoghan\" \/>\n\t<meta name=\"twitter:label2\" content=\"Estimated reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/eoghan.me.uk\/notes\/2016\/03\/28\/sftp-public-key-auth\/\",\"url\":\"https:\/\/eoghan.me.uk\/notes\/2016\/03\/28\/sftp-public-key-auth\/\",\"name\":\"Setting up Public Key Authentication for RPi SFTP - Eoghan&#039;s Notes\",\"isPartOf\":{\"@id\":\"https:\/\/eoghan.me.uk\/notes\/#website\"},\"datePublished\":\"2016-03-28T16:11:20+00:00\",\"dateModified\":\"2016-05-07T21:56:58+00:00\",\"author\":{\"@id\":\"https:\/\/eoghan.me.uk\/notes\/#\/schema\/person\/8d580b9cc431078e942962f5df92e800\"},\"description\":\"Setting up Public Key Authentication to upload files to a Secure FTP server using a Python script.\",\"breadcrumb\":{\"@id\":\"https:\/\/eoghan.me.uk\/notes\/2016\/03\/28\/sftp-public-key-auth\/#breadcrumb\"},\"inLanguage\":\"en-GB\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/eoghan.me.uk\/notes\/2016\/03\/28\/sftp-public-key-auth\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/eoghan.me.uk\/notes\/2016\/03\/28\/sftp-public-key-auth\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/eoghan.me.uk\/notes\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Setting up Public Key Authentication for RPi SFTP\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/eoghan.me.uk\/notes\/#website\",\"url\":\"https:\/\/eoghan.me.uk\/notes\/\",\"name\":\"Eoghan&#039;s Notes\",\"description\":\"The odd note that might come in handy someday\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/eoghan.me.uk\/notes\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-GB\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/eoghan.me.uk\/notes\/#\/schema\/person\/8d580b9cc431078e942962f5df92e800\",\"name\":\"Eoghan\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-GB\",\"@id\":\"https:\/\/eoghan.me.uk\/notes\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/248edf410b45769042d524cee3cce559fa8db50415efb82f79ea8a2d138b15cf?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/248edf410b45769042d524cee3cce559fa8db50415efb82f79ea8a2d138b15cf?s=96&d=mm&r=g\",\"caption\":\"Eoghan\"},\"url\":\"https:\/\/eoghan.me.uk\/notes\/author\/eoghan\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Setting up Public Key Authentication for RPi SFTP - Eoghan&#039;s Notes","description":"Setting up Public Key Authentication to upload files to a Secure FTP server using a Python script.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/eoghan.me.uk\/notes\/2016\/03\/28\/sftp-public-key-auth\/","og_locale":"en_GB","og_type":"article","og_title":"Setting up Public Key Authentication for RPi SFTP - Eoghan&#039;s Notes","og_description":"Setting up Public Key Authentication to upload files to a Secure FTP server using a Python script.","og_url":"https:\/\/eoghan.me.uk\/notes\/2016\/03\/28\/sftp-public-key-auth\/","og_site_name":"Eoghan&#039;s Notes","article_published_time":"2016-03-28T16:11:20+00:00","article_modified_time":"2016-05-07T21:56:58+00:00","author":"Eoghan","twitter_misc":{"Written by":"Eoghan","Estimated reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/eoghan.me.uk\/notes\/2016\/03\/28\/sftp-public-key-auth\/","url":"https:\/\/eoghan.me.uk\/notes\/2016\/03\/28\/sftp-public-key-auth\/","name":"Setting up Public Key Authentication for RPi SFTP - Eoghan&#039;s Notes","isPartOf":{"@id":"https:\/\/eoghan.me.uk\/notes\/#website"},"datePublished":"2016-03-28T16:11:20+00:00","dateModified":"2016-05-07T21:56:58+00:00","author":{"@id":"https:\/\/eoghan.me.uk\/notes\/#\/schema\/person\/8d580b9cc431078e942962f5df92e800"},"description":"Setting up Public Key Authentication to upload files to a Secure FTP server using a Python script.","breadcrumb":{"@id":"https:\/\/eoghan.me.uk\/notes\/2016\/03\/28\/sftp-public-key-auth\/#breadcrumb"},"inLanguage":"en-GB","potentialAction":[{"@type":"ReadAction","target":["https:\/\/eoghan.me.uk\/notes\/2016\/03\/28\/sftp-public-key-auth\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/eoghan.me.uk\/notes\/2016\/03\/28\/sftp-public-key-auth\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/eoghan.me.uk\/notes\/"},{"@type":"ListItem","position":2,"name":"Setting up Public Key Authentication for RPi SFTP"}]},{"@type":"WebSite","@id":"https:\/\/eoghan.me.uk\/notes\/#website","url":"https:\/\/eoghan.me.uk\/notes\/","name":"Eoghan&#039;s Notes","description":"The odd note that might come in handy someday","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/eoghan.me.uk\/notes\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-GB"},{"@type":"Person","@id":"https:\/\/eoghan.me.uk\/notes\/#\/schema\/person\/8d580b9cc431078e942962f5df92e800","name":"Eoghan","image":{"@type":"ImageObject","inLanguage":"en-GB","@id":"https:\/\/eoghan.me.uk\/notes\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/248edf410b45769042d524cee3cce559fa8db50415efb82f79ea8a2d138b15cf?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/248edf410b45769042d524cee3cce559fa8db50415efb82f79ea8a2d138b15cf?s=96&d=mm&r=g","caption":"Eoghan"},"url":"https:\/\/eoghan.me.uk\/notes\/author\/eoghan\/"}]}},"_links":{"self":[{"href":"https:\/\/eoghan.me.uk\/notes\/wp-json\/wp\/v2\/posts\/46","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/eoghan.me.uk\/notes\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/eoghan.me.uk\/notes\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/eoghan.me.uk\/notes\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/eoghan.me.uk\/notes\/wp-json\/wp\/v2\/comments?post=46"}],"version-history":[{"count":13,"href":"https:\/\/eoghan.me.uk\/notes\/wp-json\/wp\/v2\/posts\/46\/revisions"}],"predecessor-version":[{"id":256,"href":"https:\/\/eoghan.me.uk\/notes\/wp-json\/wp\/v2\/posts\/46\/revisions\/256"}],"wp:attachment":[{"href":"https:\/\/eoghan.me.uk\/notes\/wp-json\/wp\/v2\/media?parent=46"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/eoghan.me.uk\/notes\/wp-json\/wp\/v2\/categories?post=46"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/eoghan.me.uk\/notes\/wp-json\/wp\/v2\/tags?post=46"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}