{"id":189,"date":"2018-01-20T13:05:55","date_gmt":"2018-01-20T05:05:55","guid":{"rendered":"https:\/\/www.techcoil.com\/blog\/?p=189"},"modified":"2019-03-29T21:51:45","modified_gmt":"2019-03-29T13:51:45","slug":"how-to-setup-raspbian-stretch-lite-with-remote-configuration-over-wifi-on-first-boot","status":"publish","type":"post","link":"https:\/\/www.techcoil.com\/blog\/how-to-setup-raspbian-stretch-lite-with-remote-configuration-over-wifi-on-first-boot\/","title":{"rendered":"How to setup Raspbian Stretch Lite with remote configuration over WiFi on first boot"},"content":{"rendered":"<p>Two of the good features of Raspbian Stretch Lite is that it allows us to enable the SSH server and connect to our WiFi network before it boots up for the first time.<\/p>\n<p>Combining these two features is useful for <a href=\"https:\/\/www.techcoil.com\/blog\/tag\/raspberry-pi-zero-w\/\" rel=\"noopener noreferrer\" target=\"_blank\">projects based on Raspberry Pi Zero W<\/a> as we can configure Raspbian Stretch Lite via SSH without connecting extra peripherals to it.<\/p>\n<p>This post documents how you can enable remote configuration of your Raspbian Stretch Lite over WiFi on first boot.<\/p>\n<h2>Prerequisite hardware to install operating system onto the microSD<\/h2>\n<p>An operating system is required to be installed onto a microSD card in order to run Raspberry Pi. Hence, we will need to have a computer with a SD card reader. If your computer does not come with a <a href=\"https:\/\/www.amazon.com\/s\/ref=as_li_ss_tl?url=search-alias=electronics&field-keywords=SD+card+reader&linkCode=ll2&tag=clivsperswebs-20&linkId=123de0edca675b14f06f94419852d5f7\" rel=\"noopener noreferrer\" target=\"_blank\">SD card reader<\/a>, you have to get one.<\/p>\n<h2>Downloading a copy of Raspbian Stretch Lite for your Raspberry Pi<\/h2>\n<p>Once you had gathered all the necessary hardware, proceed to <a href=\"https:\/\/www.raspberrypi.org\/downloads\/raspbian\/\" rel=\"noopener noreferrer\" target=\"_blank\">download a version of the Raspbian<\/a> Stretch Lite operating system for your Raspberry Pi. As of this writing, the one that was available was dated 29th November 2017:<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.techcoil.com\/blog\/wp-content\/uploads\/raspbian-stretch-download-page-dated-20171129.gif\" alt=\"Raspbian Stretch download page dated 20171129\"><\/p>\n<p>Click on the <a href=\"https:\/\/downloads.raspberrypi.org\/raspbian_lite\/images\/raspbian_lite-2017-12-01\/2017-11-29-raspbian-stretch-lite.zip\"><strong>Download Zip<\/strong><\/a> button for Raspbian Stretch Lite and save the zip file onto your file system.<\/p>\n<h2>Installing Raspbian Stretch Lite on the microSD card<\/h2>\n<p>After your browser had downloaded the <code>.zip<\/code> file successfully, extract the <code>.img<\/code> file from the <code>.zip<\/code> file. The <code>.img<\/code> file is the operating system image that you will use for installing Raspbian Stretch Lite onto your microSD card.<\/p>\n<p>Typically, I <a href=\"\/blog\/an-easy-way-to-install-raspberry-pi-operating-system-on-a-mac\/\" target=\"_blank\" rel=\"noopener noreferrer\">use Etcher on my MacBook Pro to install operating system images onto microSD cards<\/a>.<\/p>\n<p>If you are using a windows machine, you can <a href=\"\/blog\/how-to-prepare-the-operating-system-to-run-your-raspberry-pi-with-your-windows-machine\/\" target=\"_blank\" rel=\"noopener noreferrer\">use Win32DiskImager to install the operating system for your Raspberry Pi<\/a>.<\/p>\n<p>If you are using a Linux desktop, you should be able to use Etcher to install the operating system for your Raspberry Pi.<\/p>\n<h2>Creating an empty ssh file and copying it to the root folder<\/h2>\n<p>Although there are <a href=\"https:\/\/www.techcoil.com\/blog\/different-ways-to-enable-ssh-server-on-raspbian-stretch\/\" rel=\"noopener noreferrer\" target=\"_blank\">different ways to enable SSH server on Raspbian Stretch<\/a> Lite, the best way is to enable on first boot.<\/p>\n<p>After you had written the Raspbian Stretch Lite image to the SD card, you can then tell Raspbian Stretch Lite that you want to enable the SSH server on first boot. <\/p>\n<p>To do so, simply create an empty file named as \"ssh\" and copy it to the root directory of the SD card:<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.techcoil.com\/blog\/wp-content\/uploads\/raspbian-stretch-lite-20171212-boot-with-ssh-file.gif\" alt=\"Raspbian Stretch Lite 20171212 boot with ssh file\" \/><\/p>\n<h2>Creating a wpa_supplicant.conf file that contains your WiFi network configuration<\/h2>\n<p>Once you got the ssh file into the root directory of the SD card, use a text editor to create a file named as \"wpa_supplicant.conf\" with content similar to the following:<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\ncountry=SG\r\nctrl_interface=DIR=\/var\/run\/wpa_supplicant GROUP=netdev\r\nupdate_config=1\r\n \r\nnetwork={\r\n        scan_ssid=1\r\n        ssid=&quot;the_2.4-hz-wireless-network&quot;\r\n        psk=&quot;the_2.4-hz-wireless-network_password&quot;\r\n        proto=WPA\r\n        key_mgmt=WPA-PSK \r\n}\r\n<\/pre>\n<p>You need to change the values for \"<code>country<\/code>\", \"<code>ssid<\/code>\", \"<code>psk<\/code>\", \"<code>proto<\/code>\" and \"<code>key_mgmt<\/code>\" to match your 2.4 Ghz Wireless network setup. <\/p>\n<p>The name of your wireless network is represented by \"<code>ssid<\/code>\". <\/p>\n<p>The password to connect to your wireless network is represented by \"psk\". <\/p>\n<p>The communication protocol used by your router is represented by \"<code>proto<\/code>\". Some acceptable values are <code>WPA<\/code> and <code>RSN<\/code>.<\/p>\n<p>The key management protocol used by your router is represented by \"<code>key_mgmt<\/code>\". Some acceptable values are \"<code>WPA-PSK<\/code>\" and \"<code>WPA-EAP<\/code>\".<\/p>\n<p>The values for \"<code>proto<\/code>\" and \"<code>key_mgmt<\/code>\" are commonly set to <code>WPA<\/code> and <code>WPA-PSK<\/code>.<\/p>\n<h2>Copying the wpa_supplicant.conf file to the root directory of the SD card<\/h2>\n<p>Once you had create the <code>wpa_supplicant.conf<\/code> file with your WiFi network configurations, you will then copy the file into the SD card:   <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.techcoil.com\/blog\/wp-content\/uploads\/raspbian-stretch-lite-20171212-boot-folder-with-wpa_supplicant-and-ssh.gif\" alt=\"Raspbian Stretch Lite 20171212 boot folder with wpa_supplicant and ssh\"\/><\/p>\n<h2>Getting the IP address that your Raspbian Stretch Lite got from your router<\/h2>\n<p>Once you had copied over the <code>wpa_supplicant.conf<\/code> file into the SD card, you can then put it into the SD card slot of your <a href=\"https:\/\/www.techcoil.com\/blog\/tag\/raspberry-pi\/\" target=\"_blank\" rel=\"noopener noreferrer\">Raspberry Pi<\/a>. When you provide power to your Raspberry Pi, you can then look at your router's address allocation table and find an entry with the name <strong>raspberrypi<\/strong>.<\/p>\n<h2>Connecting to your Raspbian Stretch Lite via SSH<\/h2>\n<p>With the IP address given by your router, you can then SSH into your Raspbian Stretch Lite to configure it. Suppose the IP address is <strong>192.168.1.123<\/strong>, you can then enter the following command into your favourite terminal program to access your Raspbian Stretch Lite:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nssh pi@192.168.1.123\r\n<\/pre>\n<p>The \"pi\" user is the default user that is created for us to configure our Raspbian Stretch Lite. When Raspbian Stretch Lite prompts for a password, enter \"raspberry\" without the quotes. This will get you into Raspbian Stretch Lite to perform further configurations.<\/p>\n\n      <ul id=\"social-sharing-buttons-list\">\n        <li class=\"facebook\">\n          <a href=\"https:\/\/www.facebook.com\/sharer\/sharer.php?u=https%3A%2F%2Fwp.me%2Fp245TQ-33\" target=\"_blank\" role=\"button\" rel=\"nofollow\">\n            <img decoding=\"async\" src=\"\/ph\/img\/3rd-party\/social-icons\/Facebook.png\" alt=\"Facebook icon\"> Share\n          <\/a>\n        <\/li>\n        <li class=\"twitter\">\n          <a href=\"https:\/\/twitter.com\/intent\/tweet?text=&url=https%3A%2F%2Fwp.me%2Fp245TQ-33&via=Techcoil_com\" target=\"_blank\" role=\"button\" rel=\"nofollow\">\n          <img decoding=\"async\" src=\"\/ph\/img\/3rd-party\/social-icons\/Twitter.png\" alt=\"Twitter icon\"> Tweet\n          <\/a>\n        <\/li>\n        <li class=\"linkedin\">\n          <a href=\"https:\/\/www.linkedin.com\/shareArticle?mini=1&title=&url=https%3A%2F%2Fwp.me%2Fp245TQ-33&source=https:\/\/www.techcoil.com\" target=\"_blank\" role=\"button\" rel=\"nofollow\">\n          <img decoding=\"async\" src=\"\/ph\/img\/3rd-party\/social-icons\/linkedin.png\" alt=\"Linkedin icon\"> Share\n          <\/a>\n        <\/li>\n        <li class=\"pinterest\">\n          <a href=\"https:\/\/pinterest.com\/pin\/create\/button\/?url=https%3A%2F%2Fwww.techcoil.com%2Fblog%2Fwp-json%2Fwp%2Fv2%2Fposts%2F189&description=\" class=\"pin-it-button\" target=\"_blank\" role=\"button\" rel=\"nofollow\" count-layout=\"horizontal\">\n          <img decoding=\"async\" src=\"\/ph\/img\/3rd-party\/social-icons\/Pinterest.png\" alt=\"Pinterest icon\"> Save\n          <\/a>\n        <\/li>\n      <\/ul>\n    ","protected":false},"excerpt":{"rendered":"<p>Two of the good features of Raspbian Stretch Lite is that it allows us to enable the SSH server and connect to our WiFi network before it boots up for the first time.<\/p>\n<p>Combining these two features is useful for <a href=\"https:\/\/www.techcoil.com\/blog\/tag\/raspberry-pi-zero-w\/\" rel=\"noopener noreferrer\" target=\"_blank\">projects based on Raspberry Pi Zero W<\/a> as we can configure Raspbian Stretch Lite via SSH without connecting extra peripherals to it.<\/p>\n<p>This post documents how you can enable remote configuration of your Raspbian Stretch Lite over WiFi on first boot.<\/p>\n","protected":false},"author":1,"featured_media":1279,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"advanced_seo_description":"","jetpack_seo_html_title":"","jetpack_seo_noindex":false,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"footnotes":""},"categories":[4],"tags":[484,240,445,350,452,438,485],"jetpack_featured_media_url":"https:\/\/www.techcoil.com\/blog\/wp-content\/uploads\/Raspbian-Logo.gif","jetpack_shortlink":"https:\/\/wp.me\/p245TQ-33","jetpack-related-posts":[],"jetpack_likes_enabled":true,"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.techcoil.com\/blog\/wp-json\/wp\/v2\/posts\/189"}],"collection":[{"href":"https:\/\/www.techcoil.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.techcoil.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.techcoil.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.techcoil.com\/blog\/wp-json\/wp\/v2\/comments?post=189"}],"version-history":[{"count":0,"href":"https:\/\/www.techcoil.com\/blog\/wp-json\/wp\/v2\/posts\/189\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.techcoil.com\/blog\/wp-json\/wp\/v2\/media\/1279"}],"wp:attachment":[{"href":"https:\/\/www.techcoil.com\/blog\/wp-json\/wp\/v2\/media?parent=189"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.techcoil.com\/blog\/wp-json\/wp\/v2\/categories?post=189"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.techcoil.com\/blog\/wp-json\/wp\/v2\/tags?post=189"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}