How to get SSH access to headless Raspbian Stretch Lite? Official way seems not to work












1















I was not able to enable ssh by putting the file into the boot folder, and yes it was created without extension from a Windows 7 machine and gets deleted after boot.



This is what should have happened:




For headless setup, SSH can be enabled by placing a file named ssh, without any extension, onto the boot partition of the SD card from another computer. When the Pi boots, it looks for the ssh file. If it is found, SSH is enabled and the file is deleted. The content of the file does not matter; it could contain text, or nothing at all.




(Source)



I don't want to go for Keyboard & Monitor as I can get the IP assigned to Respberry Pi 3 when I connect with ethernet and can also ping with 0% lost.



After looking for an answer I got to know that the ssh is not enabled and that's the reason putty returns Connection refused on every attempt.



Now I see there is cmdline.txt in the boot folder is it something that runs on every boot? Can I use to enable ssh? If yes, how to do it?



Here are all the details, let me know if something else is required.




  • My System: Windows 7 Update 1

  • Raspberry model: Raspberry Pi 3 B

  • Raspberry OS: Raspbian Stretch Lite

  • Monitor: No

  • Keyboard: No

  • Ping Request: responded with no packet loss

  • Connection Type: Ethernet

  • SSH: not enabled (How to?)


EDIT:
Now i am able to mount the 'rootfs' to my windows 7 machine with Paragon ExtFS for Windows, but don't know how to enable ssh yet, any help is appreciated










share|improve this question

























  • @KamilMaciorowski Thanks for the edit buddy, yeah i got it wrong i guess

    – Vinod Srivastav
    Dec 22 '17 at 13:35











  • If you got it wrong about command.txt/cmdline.txt then please edit your question and fix it.

    – Kamil Maciorowski
    Dec 22 '17 at 17:06











  • @KamilMaciorowski for sure, but now i mounted rootfs in Windows 7 and able to see/edit all the files.

    – Vinod Srivastav
    Dec 22 '17 at 18:31
















1















I was not able to enable ssh by putting the file into the boot folder, and yes it was created without extension from a Windows 7 machine and gets deleted after boot.



This is what should have happened:




For headless setup, SSH can be enabled by placing a file named ssh, without any extension, onto the boot partition of the SD card from another computer. When the Pi boots, it looks for the ssh file. If it is found, SSH is enabled and the file is deleted. The content of the file does not matter; it could contain text, or nothing at all.




(Source)



I don't want to go for Keyboard & Monitor as I can get the IP assigned to Respberry Pi 3 when I connect with ethernet and can also ping with 0% lost.



After looking for an answer I got to know that the ssh is not enabled and that's the reason putty returns Connection refused on every attempt.



Now I see there is cmdline.txt in the boot folder is it something that runs on every boot? Can I use to enable ssh? If yes, how to do it?



Here are all the details, let me know if something else is required.




  • My System: Windows 7 Update 1

  • Raspberry model: Raspberry Pi 3 B

  • Raspberry OS: Raspbian Stretch Lite

  • Monitor: No

  • Keyboard: No

  • Ping Request: responded with no packet loss

  • Connection Type: Ethernet

  • SSH: not enabled (How to?)


EDIT:
Now i am able to mount the 'rootfs' to my windows 7 machine with Paragon ExtFS for Windows, but don't know how to enable ssh yet, any help is appreciated










share|improve this question

























  • @KamilMaciorowski Thanks for the edit buddy, yeah i got it wrong i guess

    – Vinod Srivastav
    Dec 22 '17 at 13:35











  • If you got it wrong about command.txt/cmdline.txt then please edit your question and fix it.

    – Kamil Maciorowski
    Dec 22 '17 at 17:06











  • @KamilMaciorowski for sure, but now i mounted rootfs in Windows 7 and able to see/edit all the files.

    – Vinod Srivastav
    Dec 22 '17 at 18:31














1












1








1


0






I was not able to enable ssh by putting the file into the boot folder, and yes it was created without extension from a Windows 7 machine and gets deleted after boot.



This is what should have happened:




For headless setup, SSH can be enabled by placing a file named ssh, without any extension, onto the boot partition of the SD card from another computer. When the Pi boots, it looks for the ssh file. If it is found, SSH is enabled and the file is deleted. The content of the file does not matter; it could contain text, or nothing at all.




(Source)



I don't want to go for Keyboard & Monitor as I can get the IP assigned to Respberry Pi 3 when I connect with ethernet and can also ping with 0% lost.



After looking for an answer I got to know that the ssh is not enabled and that's the reason putty returns Connection refused on every attempt.



Now I see there is cmdline.txt in the boot folder is it something that runs on every boot? Can I use to enable ssh? If yes, how to do it?



Here are all the details, let me know if something else is required.




  • My System: Windows 7 Update 1

  • Raspberry model: Raspberry Pi 3 B

  • Raspberry OS: Raspbian Stretch Lite

  • Monitor: No

  • Keyboard: No

  • Ping Request: responded with no packet loss

  • Connection Type: Ethernet

  • SSH: not enabled (How to?)


EDIT:
Now i am able to mount the 'rootfs' to my windows 7 machine with Paragon ExtFS for Windows, but don't know how to enable ssh yet, any help is appreciated










share|improve this question
















I was not able to enable ssh by putting the file into the boot folder, and yes it was created without extension from a Windows 7 machine and gets deleted after boot.



This is what should have happened:




For headless setup, SSH can be enabled by placing a file named ssh, without any extension, onto the boot partition of the SD card from another computer. When the Pi boots, it looks for the ssh file. If it is found, SSH is enabled and the file is deleted. The content of the file does not matter; it could contain text, or nothing at all.




(Source)



I don't want to go for Keyboard & Monitor as I can get the IP assigned to Respberry Pi 3 when I connect with ethernet and can also ping with 0% lost.



After looking for an answer I got to know that the ssh is not enabled and that's the reason putty returns Connection refused on every attempt.



Now I see there is cmdline.txt in the boot folder is it something that runs on every boot? Can I use to enable ssh? If yes, how to do it?



Here are all the details, let me know if something else is required.




  • My System: Windows 7 Update 1

  • Raspberry model: Raspberry Pi 3 B

  • Raspberry OS: Raspbian Stretch Lite

  • Monitor: No

  • Keyboard: No

  • Ping Request: responded with no packet loss

  • Connection Type: Ethernet

  • SSH: not enabled (How to?)


EDIT:
Now i am able to mount the 'rootfs' to my windows 7 machine with Paragon ExtFS for Windows, but don't know how to enable ssh yet, any help is appreciated







windows-7 networking ssh putty raspberry-pi






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Dec 22 '17 at 18:39







Vinod Srivastav

















asked Dec 22 '17 at 10:40









Vinod SrivastavVinod Srivastav

13618




13618













  • @KamilMaciorowski Thanks for the edit buddy, yeah i got it wrong i guess

    – Vinod Srivastav
    Dec 22 '17 at 13:35











  • If you got it wrong about command.txt/cmdline.txt then please edit your question and fix it.

    – Kamil Maciorowski
    Dec 22 '17 at 17:06











  • @KamilMaciorowski for sure, but now i mounted rootfs in Windows 7 and able to see/edit all the files.

    – Vinod Srivastav
    Dec 22 '17 at 18:31



















  • @KamilMaciorowski Thanks for the edit buddy, yeah i got it wrong i guess

    – Vinod Srivastav
    Dec 22 '17 at 13:35











  • If you got it wrong about command.txt/cmdline.txt then please edit your question and fix it.

    – Kamil Maciorowski
    Dec 22 '17 at 17:06











  • @KamilMaciorowski for sure, but now i mounted rootfs in Windows 7 and able to see/edit all the files.

    – Vinod Srivastav
    Dec 22 '17 at 18:31

















@KamilMaciorowski Thanks for the edit buddy, yeah i got it wrong i guess

– Vinod Srivastav
Dec 22 '17 at 13:35





@KamilMaciorowski Thanks for the edit buddy, yeah i got it wrong i guess

– Vinod Srivastav
Dec 22 '17 at 13:35













If you got it wrong about command.txt/cmdline.txt then please edit your question and fix it.

– Kamil Maciorowski
Dec 22 '17 at 17:06





If you got it wrong about command.txt/cmdline.txt then please edit your question and fix it.

– Kamil Maciorowski
Dec 22 '17 at 17:06













@KamilMaciorowski for sure, but now i mounted rootfs in Windows 7 and able to see/edit all the files.

– Vinod Srivastav
Dec 22 '17 at 18:31





@KamilMaciorowski for sure, but now i mounted rootfs in Windows 7 and able to see/edit all the files.

– Vinod Srivastav
Dec 22 '17 at 18:31










3 Answers
3






active

oldest

votes


















1














Finally i was able to find an alternate way to enable ssh. I will try to summarize it here. I tried PiBakery also but it was too heavy with nodejs and keeps on crashing in every attempt.





The problem: Ext4 format is not readable form windows



So once you burn Raspbian through any img burning tool it creates two partition Boot & rootfs. The boot partition is formatted in FAT and will be only visible to windows whereas the rootfs was with Ext4 and will not be visible at all (you can confirm it by viewing it in MiniTool partition Partition Wizard)





Mission: Editing the configuration from windows to force enable ssh



My mission was to force enable ssh as it was not working with the official instructions (putting ssh file in the boot partition). So I downloaded the Paragon ExtFS for Windows which enables Windows 7 to browse/edit files in Ext4partition by mounting it as new drive.



Before that i also tried Ext2Fsd-0.69 but it was not compatible with Windows 7 and the other ext2explore-2.2.71 is only capable to view files not to edit them. Nothing worked for me





The hack: Edit /etc/rc.local file from windows 7



After googling for almost the whole day i got to know two thing




  1. Commands can be executed by editing the file /etc/rc.local in the rootfs partition

  2. Command to start ssh is /etc/init.d/ssh start


So i edited the rc.local file by placing the /etc/init.d/ssh start just before the exit 0 so that it executes on every boot, as follows



#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

# Print the IP address
_IP=$(hostname -I) || true
if [ "$_IP" ]; then
printf "My IP address is %sn" "$_IP"
fi

/etc/init.d/ssh start
exit 0


And it worked!! I know it's not a neat way but it can be helpful for someone in need. I must thank @KamilMaciorowski for his kind help & edits.



raspbian with ssh



Please comment below if you see any issue that may arise because of it.






share|improve this answer





















  • 1





    Few things: (1) SSH daemon should work fine the way it is. (2) However if you want to set it up in "the right way", run sudo systemctl enable ssh.service (see this), next remove your hack from rc.local. (3) You asked about cmdline.txt and I didn't even comment on that because of this command.txt/cmdline.txt confusion. The answer is: you cannot start a daemon from within this file because it's for passing arguments to the kernel. (4) I'm glad you found a solution; it's good you posted it here. Upvoted.

    – Kamil Maciorowski
    Dec 22 '17 at 23:32



















1














I had a similar problem. I had several Raspberry Pi's that I was reimaging after I plugged the first one in I realized I forgot to set it up properly. I then made changes to all of the SD Cards. The first Raspberry Pi did not work, but all of the other ones did. I had to reimage the SD Card, insert the ssh file, and then it worked.



You have to create the ssh file before the first boot. If you boot the SD Card once and it isn't customized, it will not work as expected.




  • Image the SD Card

  • Make the necessary changes

  • Then first boot






share|improve this answer































    0














    Sounds like you weren't working with a fresh copy of Raspbian because the official method only works the first time you boot up a fresh copy of Raspbian. After that, you have to image the card again.



    Headless Raspbian Setup with Windows 10




    1. Start with a fresh copy of Raspbian on your SD card using any standard method. If you already used the card in a Raspberry Pi, you will need to start from the beginning. When you finish, look for an external device with the label "boot." This is your Raspberry Pi boot partition.


    2. If you cannot see your boot partition in File Explorer, you might have to assign it a drive letter. One way to do this in Windows 10 is to right-click the Start menu and click "Disk Management." This will show all the partitions on your computer. Find one labeled "boot". Right-click the partition and click "Change Drive Letter and Paths..." Click "Add..." on the next dialog box and accept the default (or change it to an unused letter). After you accept those changes, you should be able to see the boot partition in File Explorer and continue on with the other instructions.


    3. Optional: Set your Raspberry Pi to connect to your WiFi network by creating a plain text file called wpa_supplicant.conf in the boot partition with your WiFi network preferences as described here. Replace YourNetworkSSID and Your Network's Passphrase in the example below:



      country=US
      ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
      update_config=1

      network={
      ssid="YourNetworkSSID"
      psk="Your Network's Passphrase"
      key_mgmt=WPA-PSK
      }



    4. Optional: Enable the SSH server by creating a file called ssh in the boot partition with no file extension. You can do that by right clicking inside the boot partition and selecting "New" then "Text Document." Use ctrl-a to select the whole file name (including the .txt) and rename it to ssh. Windows will warn you that you might be making the file unusable. That's okay.


    5. Optional only for Raspberry Pi Zero: Setup your Raspberry Pi Zero as a USB Ethernet Gadget so you can connect the micro USB port to your computer's USB port and connect to it directly as described here. Find the file called config.txt in your boot partition and edit it in Notepad (or another editor). Put dtoverlay=dwc2 at the end of the file on its own line, save and close the file. File the file called cmdline.txt in your boot partition and edit it in Notepad (or another editor). Find the word "rootwait" in that file and put another space right after it followed by modules-load=dwc2,g_ether. There should be only one line with text in that file. Don't break new lines.

    6. You might find it easier to determine the Raspberry Pi's IP address after you turn it on if you install Apple's Bonjour Print Services on your Windows machine. You can find it here or just google for it if the link dies.

    7. Eject the SD card from your computer and put it in the Raspberry Pi. If you followed step 5 above, you can connect the Raspberry Pi directly to your computer's USB port. If you followed steps 4 and 6, you should be able to ssh to the address raspberrypi.local which was assigned by Apple's Bonjour Print Services. Otherwise, power it up as you would normally and connect via Ethernet or WiFi or however you were planning on doing it.


    Enjoy!






    share|improve this answer


























    • Thanks, but it was the latest img in a new card itself which is again formatted with Mini Tool as FAT32. I know the official way but in the questionnaire i was trying to answer how to do it when the official version don't work for you

      – Vinod Srivastav
      Jan 8 '18 at 12:03











    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "3"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1279354%2fhow-to-get-ssh-access-to-headless-raspbian-stretch-lite-official-way-seems-not%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    3 Answers
    3






    active

    oldest

    votes








    3 Answers
    3






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    Finally i was able to find an alternate way to enable ssh. I will try to summarize it here. I tried PiBakery also but it was too heavy with nodejs and keeps on crashing in every attempt.





    The problem: Ext4 format is not readable form windows



    So once you burn Raspbian through any img burning tool it creates two partition Boot & rootfs. The boot partition is formatted in FAT and will be only visible to windows whereas the rootfs was with Ext4 and will not be visible at all (you can confirm it by viewing it in MiniTool partition Partition Wizard)





    Mission: Editing the configuration from windows to force enable ssh



    My mission was to force enable ssh as it was not working with the official instructions (putting ssh file in the boot partition). So I downloaded the Paragon ExtFS for Windows which enables Windows 7 to browse/edit files in Ext4partition by mounting it as new drive.



    Before that i also tried Ext2Fsd-0.69 but it was not compatible with Windows 7 and the other ext2explore-2.2.71 is only capable to view files not to edit them. Nothing worked for me





    The hack: Edit /etc/rc.local file from windows 7



    After googling for almost the whole day i got to know two thing




    1. Commands can be executed by editing the file /etc/rc.local in the rootfs partition

    2. Command to start ssh is /etc/init.d/ssh start


    So i edited the rc.local file by placing the /etc/init.d/ssh start just before the exit 0 so that it executes on every boot, as follows



    #!/bin/sh -e
    #
    # rc.local
    #
    # This script is executed at the end of each multiuser runlevel.
    # Make sure that the script will "exit 0" on success or any other
    # value on error.
    #
    # In order to enable or disable this script just change the execution
    # bits.
    #
    # By default this script does nothing.

    # Print the IP address
    _IP=$(hostname -I) || true
    if [ "$_IP" ]; then
    printf "My IP address is %sn" "$_IP"
    fi

    /etc/init.d/ssh start
    exit 0


    And it worked!! I know it's not a neat way but it can be helpful for someone in need. I must thank @KamilMaciorowski for his kind help & edits.



    raspbian with ssh



    Please comment below if you see any issue that may arise because of it.






    share|improve this answer





















    • 1





      Few things: (1) SSH daemon should work fine the way it is. (2) However if you want to set it up in "the right way", run sudo systemctl enable ssh.service (see this), next remove your hack from rc.local. (3) You asked about cmdline.txt and I didn't even comment on that because of this command.txt/cmdline.txt confusion. The answer is: you cannot start a daemon from within this file because it's for passing arguments to the kernel. (4) I'm glad you found a solution; it's good you posted it here. Upvoted.

      – Kamil Maciorowski
      Dec 22 '17 at 23:32
















    1














    Finally i was able to find an alternate way to enable ssh. I will try to summarize it here. I tried PiBakery also but it was too heavy with nodejs and keeps on crashing in every attempt.





    The problem: Ext4 format is not readable form windows



    So once you burn Raspbian through any img burning tool it creates two partition Boot & rootfs. The boot partition is formatted in FAT and will be only visible to windows whereas the rootfs was with Ext4 and will not be visible at all (you can confirm it by viewing it in MiniTool partition Partition Wizard)





    Mission: Editing the configuration from windows to force enable ssh



    My mission was to force enable ssh as it was not working with the official instructions (putting ssh file in the boot partition). So I downloaded the Paragon ExtFS for Windows which enables Windows 7 to browse/edit files in Ext4partition by mounting it as new drive.



    Before that i also tried Ext2Fsd-0.69 but it was not compatible with Windows 7 and the other ext2explore-2.2.71 is only capable to view files not to edit them. Nothing worked for me





    The hack: Edit /etc/rc.local file from windows 7



    After googling for almost the whole day i got to know two thing




    1. Commands can be executed by editing the file /etc/rc.local in the rootfs partition

    2. Command to start ssh is /etc/init.d/ssh start


    So i edited the rc.local file by placing the /etc/init.d/ssh start just before the exit 0 so that it executes on every boot, as follows



    #!/bin/sh -e
    #
    # rc.local
    #
    # This script is executed at the end of each multiuser runlevel.
    # Make sure that the script will "exit 0" on success or any other
    # value on error.
    #
    # In order to enable or disable this script just change the execution
    # bits.
    #
    # By default this script does nothing.

    # Print the IP address
    _IP=$(hostname -I) || true
    if [ "$_IP" ]; then
    printf "My IP address is %sn" "$_IP"
    fi

    /etc/init.d/ssh start
    exit 0


    And it worked!! I know it's not a neat way but it can be helpful for someone in need. I must thank @KamilMaciorowski for his kind help & edits.



    raspbian with ssh



    Please comment below if you see any issue that may arise because of it.






    share|improve this answer





















    • 1





      Few things: (1) SSH daemon should work fine the way it is. (2) However if you want to set it up in "the right way", run sudo systemctl enable ssh.service (see this), next remove your hack from rc.local. (3) You asked about cmdline.txt and I didn't even comment on that because of this command.txt/cmdline.txt confusion. The answer is: you cannot start a daemon from within this file because it's for passing arguments to the kernel. (4) I'm glad you found a solution; it's good you posted it here. Upvoted.

      – Kamil Maciorowski
      Dec 22 '17 at 23:32














    1












    1








    1







    Finally i was able to find an alternate way to enable ssh. I will try to summarize it here. I tried PiBakery also but it was too heavy with nodejs and keeps on crashing in every attempt.





    The problem: Ext4 format is not readable form windows



    So once you burn Raspbian through any img burning tool it creates two partition Boot & rootfs. The boot partition is formatted in FAT and will be only visible to windows whereas the rootfs was with Ext4 and will not be visible at all (you can confirm it by viewing it in MiniTool partition Partition Wizard)





    Mission: Editing the configuration from windows to force enable ssh



    My mission was to force enable ssh as it was not working with the official instructions (putting ssh file in the boot partition). So I downloaded the Paragon ExtFS for Windows which enables Windows 7 to browse/edit files in Ext4partition by mounting it as new drive.



    Before that i also tried Ext2Fsd-0.69 but it was not compatible with Windows 7 and the other ext2explore-2.2.71 is only capable to view files not to edit them. Nothing worked for me





    The hack: Edit /etc/rc.local file from windows 7



    After googling for almost the whole day i got to know two thing




    1. Commands can be executed by editing the file /etc/rc.local in the rootfs partition

    2. Command to start ssh is /etc/init.d/ssh start


    So i edited the rc.local file by placing the /etc/init.d/ssh start just before the exit 0 so that it executes on every boot, as follows



    #!/bin/sh -e
    #
    # rc.local
    #
    # This script is executed at the end of each multiuser runlevel.
    # Make sure that the script will "exit 0" on success or any other
    # value on error.
    #
    # In order to enable or disable this script just change the execution
    # bits.
    #
    # By default this script does nothing.

    # Print the IP address
    _IP=$(hostname -I) || true
    if [ "$_IP" ]; then
    printf "My IP address is %sn" "$_IP"
    fi

    /etc/init.d/ssh start
    exit 0


    And it worked!! I know it's not a neat way but it can be helpful for someone in need. I must thank @KamilMaciorowski for his kind help & edits.



    raspbian with ssh



    Please comment below if you see any issue that may arise because of it.






    share|improve this answer















    Finally i was able to find an alternate way to enable ssh. I will try to summarize it here. I tried PiBakery also but it was too heavy with nodejs and keeps on crashing in every attempt.





    The problem: Ext4 format is not readable form windows



    So once you burn Raspbian through any img burning tool it creates two partition Boot & rootfs. The boot partition is formatted in FAT and will be only visible to windows whereas the rootfs was with Ext4 and will not be visible at all (you can confirm it by viewing it in MiniTool partition Partition Wizard)





    Mission: Editing the configuration from windows to force enable ssh



    My mission was to force enable ssh as it was not working with the official instructions (putting ssh file in the boot partition). So I downloaded the Paragon ExtFS for Windows which enables Windows 7 to browse/edit files in Ext4partition by mounting it as new drive.



    Before that i also tried Ext2Fsd-0.69 but it was not compatible with Windows 7 and the other ext2explore-2.2.71 is only capable to view files not to edit them. Nothing worked for me





    The hack: Edit /etc/rc.local file from windows 7



    After googling for almost the whole day i got to know two thing




    1. Commands can be executed by editing the file /etc/rc.local in the rootfs partition

    2. Command to start ssh is /etc/init.d/ssh start


    So i edited the rc.local file by placing the /etc/init.d/ssh start just before the exit 0 so that it executes on every boot, as follows



    #!/bin/sh -e
    #
    # rc.local
    #
    # This script is executed at the end of each multiuser runlevel.
    # Make sure that the script will "exit 0" on success or any other
    # value on error.
    #
    # In order to enable or disable this script just change the execution
    # bits.
    #
    # By default this script does nothing.

    # Print the IP address
    _IP=$(hostname -I) || true
    if [ "$_IP" ]; then
    printf "My IP address is %sn" "$_IP"
    fi

    /etc/init.d/ssh start
    exit 0


    And it worked!! I know it's not a neat way but it can be helpful for someone in need. I must thank @KamilMaciorowski for his kind help & edits.



    raspbian with ssh



    Please comment below if you see any issue that may arise because of it.







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Dec 22 '17 at 23:16









    Kamil Maciorowski

    25.7k155578




    25.7k155578










    answered Dec 22 '17 at 22:59









    Vinod SrivastavVinod Srivastav

    13618




    13618








    • 1





      Few things: (1) SSH daemon should work fine the way it is. (2) However if you want to set it up in "the right way", run sudo systemctl enable ssh.service (see this), next remove your hack from rc.local. (3) You asked about cmdline.txt and I didn't even comment on that because of this command.txt/cmdline.txt confusion. The answer is: you cannot start a daemon from within this file because it's for passing arguments to the kernel. (4) I'm glad you found a solution; it's good you posted it here. Upvoted.

      – Kamil Maciorowski
      Dec 22 '17 at 23:32














    • 1





      Few things: (1) SSH daemon should work fine the way it is. (2) However if you want to set it up in "the right way", run sudo systemctl enable ssh.service (see this), next remove your hack from rc.local. (3) You asked about cmdline.txt and I didn't even comment on that because of this command.txt/cmdline.txt confusion. The answer is: you cannot start a daemon from within this file because it's for passing arguments to the kernel. (4) I'm glad you found a solution; it's good you posted it here. Upvoted.

      – Kamil Maciorowski
      Dec 22 '17 at 23:32








    1




    1





    Few things: (1) SSH daemon should work fine the way it is. (2) However if you want to set it up in "the right way", run sudo systemctl enable ssh.service (see this), next remove your hack from rc.local. (3) You asked about cmdline.txt and I didn't even comment on that because of this command.txt/cmdline.txt confusion. The answer is: you cannot start a daemon from within this file because it's for passing arguments to the kernel. (4) I'm glad you found a solution; it's good you posted it here. Upvoted.

    – Kamil Maciorowski
    Dec 22 '17 at 23:32





    Few things: (1) SSH daemon should work fine the way it is. (2) However if you want to set it up in "the right way", run sudo systemctl enable ssh.service (see this), next remove your hack from rc.local. (3) You asked about cmdline.txt and I didn't even comment on that because of this command.txt/cmdline.txt confusion. The answer is: you cannot start a daemon from within this file because it's for passing arguments to the kernel. (4) I'm glad you found a solution; it's good you posted it here. Upvoted.

    – Kamil Maciorowski
    Dec 22 '17 at 23:32













    1














    I had a similar problem. I had several Raspberry Pi's that I was reimaging after I plugged the first one in I realized I forgot to set it up properly. I then made changes to all of the SD Cards. The first Raspberry Pi did not work, but all of the other ones did. I had to reimage the SD Card, insert the ssh file, and then it worked.



    You have to create the ssh file before the first boot. If you boot the SD Card once and it isn't customized, it will not work as expected.




    • Image the SD Card

    • Make the necessary changes

    • Then first boot






    share|improve this answer




























      1














      I had a similar problem. I had several Raspberry Pi's that I was reimaging after I plugged the first one in I realized I forgot to set it up properly. I then made changes to all of the SD Cards. The first Raspberry Pi did not work, but all of the other ones did. I had to reimage the SD Card, insert the ssh file, and then it worked.



      You have to create the ssh file before the first boot. If you boot the SD Card once and it isn't customized, it will not work as expected.




      • Image the SD Card

      • Make the necessary changes

      • Then first boot






      share|improve this answer


























        1












        1








        1







        I had a similar problem. I had several Raspberry Pi's that I was reimaging after I plugged the first one in I realized I forgot to set it up properly. I then made changes to all of the SD Cards. The first Raspberry Pi did not work, but all of the other ones did. I had to reimage the SD Card, insert the ssh file, and then it worked.



        You have to create the ssh file before the first boot. If you boot the SD Card once and it isn't customized, it will not work as expected.




        • Image the SD Card

        • Make the necessary changes

        • Then first boot






        share|improve this answer













        I had a similar problem. I had several Raspberry Pi's that I was reimaging after I plugged the first one in I realized I forgot to set it up properly. I then made changes to all of the SD Cards. The first Raspberry Pi did not work, but all of the other ones did. I had to reimage the SD Card, insert the ssh file, and then it worked.



        You have to create the ssh file before the first boot. If you boot the SD Card once and it isn't customized, it will not work as expected.




        • Image the SD Card

        • Make the necessary changes

        • Then first boot







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Jan 1 at 21:25









        AggieBillAggieBill

        111




        111























            0














            Sounds like you weren't working with a fresh copy of Raspbian because the official method only works the first time you boot up a fresh copy of Raspbian. After that, you have to image the card again.



            Headless Raspbian Setup with Windows 10




            1. Start with a fresh copy of Raspbian on your SD card using any standard method. If you already used the card in a Raspberry Pi, you will need to start from the beginning. When you finish, look for an external device with the label "boot." This is your Raspberry Pi boot partition.


            2. If you cannot see your boot partition in File Explorer, you might have to assign it a drive letter. One way to do this in Windows 10 is to right-click the Start menu and click "Disk Management." This will show all the partitions on your computer. Find one labeled "boot". Right-click the partition and click "Change Drive Letter and Paths..." Click "Add..." on the next dialog box and accept the default (or change it to an unused letter). After you accept those changes, you should be able to see the boot partition in File Explorer and continue on with the other instructions.


            3. Optional: Set your Raspberry Pi to connect to your WiFi network by creating a plain text file called wpa_supplicant.conf in the boot partition with your WiFi network preferences as described here. Replace YourNetworkSSID and Your Network's Passphrase in the example below:



              country=US
              ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
              update_config=1

              network={
              ssid="YourNetworkSSID"
              psk="Your Network's Passphrase"
              key_mgmt=WPA-PSK
              }



            4. Optional: Enable the SSH server by creating a file called ssh in the boot partition with no file extension. You can do that by right clicking inside the boot partition and selecting "New" then "Text Document." Use ctrl-a to select the whole file name (including the .txt) and rename it to ssh. Windows will warn you that you might be making the file unusable. That's okay.


            5. Optional only for Raspberry Pi Zero: Setup your Raspberry Pi Zero as a USB Ethernet Gadget so you can connect the micro USB port to your computer's USB port and connect to it directly as described here. Find the file called config.txt in your boot partition and edit it in Notepad (or another editor). Put dtoverlay=dwc2 at the end of the file on its own line, save and close the file. File the file called cmdline.txt in your boot partition and edit it in Notepad (or another editor). Find the word "rootwait" in that file and put another space right after it followed by modules-load=dwc2,g_ether. There should be only one line with text in that file. Don't break new lines.

            6. You might find it easier to determine the Raspberry Pi's IP address after you turn it on if you install Apple's Bonjour Print Services on your Windows machine. You can find it here or just google for it if the link dies.

            7. Eject the SD card from your computer and put it in the Raspberry Pi. If you followed step 5 above, you can connect the Raspberry Pi directly to your computer's USB port. If you followed steps 4 and 6, you should be able to ssh to the address raspberrypi.local which was assigned by Apple's Bonjour Print Services. Otherwise, power it up as you would normally and connect via Ethernet or WiFi or however you were planning on doing it.


            Enjoy!






            share|improve this answer


























            • Thanks, but it was the latest img in a new card itself which is again formatted with Mini Tool as FAT32. I know the official way but in the questionnaire i was trying to answer how to do it when the official version don't work for you

              – Vinod Srivastav
              Jan 8 '18 at 12:03
















            0














            Sounds like you weren't working with a fresh copy of Raspbian because the official method only works the first time you boot up a fresh copy of Raspbian. After that, you have to image the card again.



            Headless Raspbian Setup with Windows 10




            1. Start with a fresh copy of Raspbian on your SD card using any standard method. If you already used the card in a Raspberry Pi, you will need to start from the beginning. When you finish, look for an external device with the label "boot." This is your Raspberry Pi boot partition.


            2. If you cannot see your boot partition in File Explorer, you might have to assign it a drive letter. One way to do this in Windows 10 is to right-click the Start menu and click "Disk Management." This will show all the partitions on your computer. Find one labeled "boot". Right-click the partition and click "Change Drive Letter and Paths..." Click "Add..." on the next dialog box and accept the default (or change it to an unused letter). After you accept those changes, you should be able to see the boot partition in File Explorer and continue on with the other instructions.


            3. Optional: Set your Raspberry Pi to connect to your WiFi network by creating a plain text file called wpa_supplicant.conf in the boot partition with your WiFi network preferences as described here. Replace YourNetworkSSID and Your Network's Passphrase in the example below:



              country=US
              ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
              update_config=1

              network={
              ssid="YourNetworkSSID"
              psk="Your Network's Passphrase"
              key_mgmt=WPA-PSK
              }



            4. Optional: Enable the SSH server by creating a file called ssh in the boot partition with no file extension. You can do that by right clicking inside the boot partition and selecting "New" then "Text Document." Use ctrl-a to select the whole file name (including the .txt) and rename it to ssh. Windows will warn you that you might be making the file unusable. That's okay.


            5. Optional only for Raspberry Pi Zero: Setup your Raspberry Pi Zero as a USB Ethernet Gadget so you can connect the micro USB port to your computer's USB port and connect to it directly as described here. Find the file called config.txt in your boot partition and edit it in Notepad (or another editor). Put dtoverlay=dwc2 at the end of the file on its own line, save and close the file. File the file called cmdline.txt in your boot partition and edit it in Notepad (or another editor). Find the word "rootwait" in that file and put another space right after it followed by modules-load=dwc2,g_ether. There should be only one line with text in that file. Don't break new lines.

            6. You might find it easier to determine the Raspberry Pi's IP address after you turn it on if you install Apple's Bonjour Print Services on your Windows machine. You can find it here or just google for it if the link dies.

            7. Eject the SD card from your computer and put it in the Raspberry Pi. If you followed step 5 above, you can connect the Raspberry Pi directly to your computer's USB port. If you followed steps 4 and 6, you should be able to ssh to the address raspberrypi.local which was assigned by Apple's Bonjour Print Services. Otherwise, power it up as you would normally and connect via Ethernet or WiFi or however you were planning on doing it.


            Enjoy!






            share|improve this answer


























            • Thanks, but it was the latest img in a new card itself which is again formatted with Mini Tool as FAT32. I know the official way but in the questionnaire i was trying to answer how to do it when the official version don't work for you

              – Vinod Srivastav
              Jan 8 '18 at 12:03














            0












            0








            0







            Sounds like you weren't working with a fresh copy of Raspbian because the official method only works the first time you boot up a fresh copy of Raspbian. After that, you have to image the card again.



            Headless Raspbian Setup with Windows 10




            1. Start with a fresh copy of Raspbian on your SD card using any standard method. If you already used the card in a Raspberry Pi, you will need to start from the beginning. When you finish, look for an external device with the label "boot." This is your Raspberry Pi boot partition.


            2. If you cannot see your boot partition in File Explorer, you might have to assign it a drive letter. One way to do this in Windows 10 is to right-click the Start menu and click "Disk Management." This will show all the partitions on your computer. Find one labeled "boot". Right-click the partition and click "Change Drive Letter and Paths..." Click "Add..." on the next dialog box and accept the default (or change it to an unused letter). After you accept those changes, you should be able to see the boot partition in File Explorer and continue on with the other instructions.


            3. Optional: Set your Raspberry Pi to connect to your WiFi network by creating a plain text file called wpa_supplicant.conf in the boot partition with your WiFi network preferences as described here. Replace YourNetworkSSID and Your Network's Passphrase in the example below:



              country=US
              ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
              update_config=1

              network={
              ssid="YourNetworkSSID"
              psk="Your Network's Passphrase"
              key_mgmt=WPA-PSK
              }



            4. Optional: Enable the SSH server by creating a file called ssh in the boot partition with no file extension. You can do that by right clicking inside the boot partition and selecting "New" then "Text Document." Use ctrl-a to select the whole file name (including the .txt) and rename it to ssh. Windows will warn you that you might be making the file unusable. That's okay.


            5. Optional only for Raspberry Pi Zero: Setup your Raspberry Pi Zero as a USB Ethernet Gadget so you can connect the micro USB port to your computer's USB port and connect to it directly as described here. Find the file called config.txt in your boot partition and edit it in Notepad (or another editor). Put dtoverlay=dwc2 at the end of the file on its own line, save and close the file. File the file called cmdline.txt in your boot partition and edit it in Notepad (or another editor). Find the word "rootwait" in that file and put another space right after it followed by modules-load=dwc2,g_ether. There should be only one line with text in that file. Don't break new lines.

            6. You might find it easier to determine the Raspberry Pi's IP address after you turn it on if you install Apple's Bonjour Print Services on your Windows machine. You can find it here or just google for it if the link dies.

            7. Eject the SD card from your computer and put it in the Raspberry Pi. If you followed step 5 above, you can connect the Raspberry Pi directly to your computer's USB port. If you followed steps 4 and 6, you should be able to ssh to the address raspberrypi.local which was assigned by Apple's Bonjour Print Services. Otherwise, power it up as you would normally and connect via Ethernet or WiFi or however you were planning on doing it.


            Enjoy!






            share|improve this answer















            Sounds like you weren't working with a fresh copy of Raspbian because the official method only works the first time you boot up a fresh copy of Raspbian. After that, you have to image the card again.



            Headless Raspbian Setup with Windows 10




            1. Start with a fresh copy of Raspbian on your SD card using any standard method. If you already used the card in a Raspberry Pi, you will need to start from the beginning. When you finish, look for an external device with the label "boot." This is your Raspberry Pi boot partition.


            2. If you cannot see your boot partition in File Explorer, you might have to assign it a drive letter. One way to do this in Windows 10 is to right-click the Start menu and click "Disk Management." This will show all the partitions on your computer. Find one labeled "boot". Right-click the partition and click "Change Drive Letter and Paths..." Click "Add..." on the next dialog box and accept the default (or change it to an unused letter). After you accept those changes, you should be able to see the boot partition in File Explorer and continue on with the other instructions.


            3. Optional: Set your Raspberry Pi to connect to your WiFi network by creating a plain text file called wpa_supplicant.conf in the boot partition with your WiFi network preferences as described here. Replace YourNetworkSSID and Your Network's Passphrase in the example below:



              country=US
              ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
              update_config=1

              network={
              ssid="YourNetworkSSID"
              psk="Your Network's Passphrase"
              key_mgmt=WPA-PSK
              }



            4. Optional: Enable the SSH server by creating a file called ssh in the boot partition with no file extension. You can do that by right clicking inside the boot partition and selecting "New" then "Text Document." Use ctrl-a to select the whole file name (including the .txt) and rename it to ssh. Windows will warn you that you might be making the file unusable. That's okay.


            5. Optional only for Raspberry Pi Zero: Setup your Raspberry Pi Zero as a USB Ethernet Gadget so you can connect the micro USB port to your computer's USB port and connect to it directly as described here. Find the file called config.txt in your boot partition and edit it in Notepad (or another editor). Put dtoverlay=dwc2 at the end of the file on its own line, save and close the file. File the file called cmdline.txt in your boot partition and edit it in Notepad (or another editor). Find the word "rootwait" in that file and put another space right after it followed by modules-load=dwc2,g_ether. There should be only one line with text in that file. Don't break new lines.

            6. You might find it easier to determine the Raspberry Pi's IP address after you turn it on if you install Apple's Bonjour Print Services on your Windows machine. You can find it here or just google for it if the link dies.

            7. Eject the SD card from your computer and put it in the Raspberry Pi. If you followed step 5 above, you can connect the Raspberry Pi directly to your computer's USB port. If you followed steps 4 and 6, you should be able to ssh to the address raspberrypi.local which was assigned by Apple's Bonjour Print Services. Otherwise, power it up as you would normally and connect via Ethernet or WiFi or however you were planning on doing it.


            Enjoy!







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Jan 20 '18 at 22:28

























            answered Jan 4 '18 at 23:12









            FlippingBinaryFlippingBinary

            1011




            1011













            • Thanks, but it was the latest img in a new card itself which is again formatted with Mini Tool as FAT32. I know the official way but in the questionnaire i was trying to answer how to do it when the official version don't work for you

              – Vinod Srivastav
              Jan 8 '18 at 12:03



















            • Thanks, but it was the latest img in a new card itself which is again formatted with Mini Tool as FAT32. I know the official way but in the questionnaire i was trying to answer how to do it when the official version don't work for you

              – Vinod Srivastav
              Jan 8 '18 at 12:03

















            Thanks, but it was the latest img in a new card itself which is again formatted with Mini Tool as FAT32. I know the official way but in the questionnaire i was trying to answer how to do it when the official version don't work for you

            – Vinod Srivastav
            Jan 8 '18 at 12:03





            Thanks, but it was the latest img in a new card itself which is again formatted with Mini Tool as FAT32. I know the official way but in the questionnaire i was trying to answer how to do it when the official version don't work for you

            – Vinod Srivastav
            Jan 8 '18 at 12:03


















            draft saved

            draft discarded




















































            Thanks for contributing an answer to Super User!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1279354%2fhow-to-get-ssh-access-to-headless-raspbian-stretch-lite-official-way-seems-not%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            flock() on closed filehandle LOCK_FILE at /usr/bin/apt-mirror

            Mangá

            Eduardo VII do Reino Unido