1. Got a question or need help troubleshooting? Post to the troubleshooting forum or Search the forums!

Enabling SSH

Discussion in 'General Questions' started by Jerome Helbert, Aug 21, 2018.

  1. Jerome Helbert

    Joined:
    Aug 19, 2017
    Messages:
    34
    Likes Received:
    12
    I can't seem to get SSH working on my R2 after a software update awhile back. Prior to that I had no issues.

    I've tried placing an empty txt file on the boot partition named ssh, but I still get a "connection refused" response when I try to connect.

    Am I missing something, or is there anything else I can try?
     
  2. mark tomlinson

    mark tomlinson ༼ つ ◕_ ◕ ༽つ
    Staff Member

    Joined:
    Feb 21, 2013
    Messages:
    20,477
    Likes Received:
    6,879
    Not sure how you do it without logging into Raspbian (but I am not a Pi OS guru).
    I always just :


    1. Enter sudo raspi-config in a terminal window.
    2. Select Interfacing Options.
    3. Navigate to and select SSH.
    4. Choose Yes.
    5. Select Ok.
    6. Choose Finish.

    I think the approach you are taking is valid only for Rasbian Lite:

    "For headless setup,SSH can be enabled by placing a file named 'ssh', without any extension, onto the boot partition of the SD card."

    You can use putty to connect and run raspi-config that way too
     
  3. mark tomlinson

    mark tomlinson ༼ つ ◕_ ◕ ༽つ
    Staff Member

    Joined:
    Feb 21, 2013
    Messages:
    20,477
    Likes Received:
    6,879
    Also, details of how you are trying to connect would be handy
     
  4. Jerome Helbert

    Joined:
    Aug 19, 2017
    Messages:
    34
    Likes Received:
    12
    How are you connecting to the Pi to run raspi-config, you say to use the terminal? So far I haven't wired anything else to the Pi or changed anything with its connections, so all I have is whats on the sd card. Putty is still just going to be ssh, so it wont work until I have SSH enabled.

    I did some digging, and it looks like the "ssh file on the boot partition" thing only works the first time the card is booted from after creation. Since I am dealing with an already running system, or from the factory fresh image I just requested from Robo (which I assume is a clone of a setup that has already been booted once) that wont work

    I'm hoping I answered my question, I found this link that should get me going (I'll try it out once I get back home) https://superuser.com/questions/127...h-lite-official-way-seems-not/1279491#1279491

    It essentially mounts the rootfs filesystem, then you can make ssh start directly. Once into the system via ssh you can run raspi-config to enable it properly.
     
    #4 Jerome Helbert, Aug 21, 2018
    Last edited: Aug 21, 2018
  5. mark tomlinson

    mark tomlinson ༼ つ ◕_ ◕ ༽つ
    Staff Member

    Joined:
    Feb 21, 2013
    Messages:
    20,477
    Likes Received:
    6,879
    With a network cable :) The network/LAN connector that comes out the back runs directly to the Pi. Plug it into a switch/router and it is on the netwrok/LAN and you can putty directly in.

    If you only want or have WiFi available then you are stuck getting it to work without being able to boot it and login and ... I can't really advise you there. All of our RaspberryPi's start out on the LAN.

    And no, putty does not insist on SSH you can jolly well use Putty into a non-ssh pi :)
     
  6. Jerome Helbert

    Joined:
    Aug 19, 2017
    Messages:
    34
    Likes Received:
    12
    I am plugged in via ethernet (I limit my Wifi to mobile devices to limit congestion) and yeah... I think you are missing some bits there... Putty needs a protocol to use (Direct serial over COM port, telnet, ssh, etc), and isn't a means of talking in and of itself. Ie, nothing "speaks" putty, but Putty speaks various protocols.

    You plug ethernet in or hook up WiFi and it all ends up in the same networking subsystem on the Pi, so it shouldn't matter which network device is in use. Maybe they have ssh over wifi specifically locked down in firewall or something crazy, but that would take a fair bit of work to split the two out.
     
  7. mark tomlinson

    mark tomlinson ༼ つ ◕_ ◕ ༽つ
    Staff Member

    Joined:
    Feb 21, 2013
    Messages:
    20,477
    Likes Received:
    6,879
    If you plug in your ethernet/router via the ehternet connector on the back the Pi will get an IP address andbe reachable via putty (TCP/IP) over that cable. You can either use the LCD to get the IP address for telnet in via putty or look on the Router and see what IP it handed out.
     
  8. mark tomlinson

    mark tomlinson ༼ つ ◕_ ◕ ༽つ
    Staff Member

    Joined:
    Feb 21, 2013
    Messages:
    20,477
    Likes Received:
    6,879
    Once you get connected via putty or whatever over the TCP connection you can enable SSH, WiFi, whatever ever else you need from the command line. I can provide details on that if you need.
     
  9. Jerome Helbert

    Joined:
    Aug 19, 2017
    Messages:
    34
    Likes Received:
    12
    A
    Again... Putty using what protocol/interface? You have to choose the connection type (see attached)

    The default is SSH so you have to be changing it to something.
     

    Attached Files:

  10. mark tomlinson

    mark tomlinson ༼ つ ◕_ ◕ ༽つ
    Staff Member

    Joined:
    Feb 21, 2013
    Messages:
    20,477
    Likes Received:
    6,879

    telnet...the original terminal protocol. :)
     
  11. Jerome Helbert

    Joined:
    Aug 19, 2017
    Messages:
    34
    Likes Received:
    12
    lol, but not the Putty default (see why I kept asking ;) )

    thanks, I didn't even think about the possibility of them locking down ssh access for security reasons - but not telnet... I'll give this a try when I get home. If nothing else I am reasonable confident the approach I linked to would also work if telnet weren't open.
     
  12. mark tomlinson

    mark tomlinson ༼ つ ◕_ ◕ ༽つ
    Staff Member

    Joined:
    Feb 21, 2013
    Messages:
    20,477
    Likes Received:
    6,879
    Honestly? The Pi should just come configured for SSL.

    I am a little perplexed over yours though because Even on an out-of-the-box Pi 3 I was able to SSH in when I booted in to the latest version of Raspbian. Nothing to configure, same exact way I would go in to the printer ones... SSH worked fine (no telnet required) so something else may be going on there.
     
  13. mark tomlinson

    mark tomlinson ༼ つ ◕_ ◕ ༽つ
    Staff Member

    Joined:
    Feb 21, 2013
    Messages:
    20,477
    Likes Received:
    6,879
    Also I can confirm that on the C2 at least the OS image had nothing overtly configured differently for networking...AFAIK the R2/C2 still use the exact same OS image.
     
  14. Jerome Helbert

    Joined:
    Aug 19, 2017
    Messages:
    34
    Likes Received:
    12
    From section 2 of this page: https://www.raspberrypi.org/documentation/remote-access/ssh/
    "As of the November 2016 release, Raspbian has the SSH server disabled by default. It can be enabled manually from the desktop"

    I used to have perfectly functional SSH until the last OS update from Robo. At the time I was doing considerably less poking around the internals, so I never really worried much about it (expecting to be able to turn it back on when I wanted to.) I just figured that Robo had followed RPi's recommendations and locked it down and/or decided to lock it down to prevent people from bricking their printers.

    Now I am back to wanting to make customization to some behaviors, and I can't get any of the normal steps to work. I even requested a factory fresh image thinking I had borked something up and it behaved the same way.
     
  15. mark tomlinson

    mark tomlinson ༼ つ ◕_ ◕ ༽つ
    Staff Member

    Joined:
    Feb 21, 2013
    Messages:
    20,477
    Likes Received:
    6,879
    Hmm, then perhaps the pi I just opened and booted is using an older version of Raspbian than I imagined -- I did not download a fresh copy and burn it to an SD card, I just grabbed one of my Raspbian SD cards on the desk*.

    You are not going to have the desktop as an option unless you plug directly in with video or unless VNC server is running (mine are, but I am sure it is not by default). While the cable is doable, that is a royal pain.
    Maybe they have telnet disabled now as well -- that would make sense otherwise it defeats the purpose of turning off SSH :)


    *I could have sworn it was using stretch...(or maybe I had already enabled that one and forgotten).
    You could always try the Pi image I have :) For the C2 (should work fine on the R2). PM me if you want to do that and I will stage it on OneDrive or GoogleDrive or something.
     
    #15 mark tomlinson, Aug 21, 2018
    Last edited: Aug 21, 2018
  16. Jerome Helbert

    Joined:
    Aug 19, 2017
    Messages:
    34
    Likes Received:
    12
    Yeah, and not having desktop is where the post that I linked to comes in. Basically you mount the rootfs (which is formatted ext4 and windows doesn't understand without some helper programs) and you edit rc.local to start the ssh service on boot. This will let me ssh in the first time, where I can then enable ssh the proper way via raspi-config and then remove my hack.

    I'll try telnet first since that would be a million times easier, but given the difference in behaviors between our two Pis, I am betting its probably not on by default either.
     
  17. mark tomlinson

    mark tomlinson ༼ つ ◕_ ◕ ༽つ
    Staff Member

    Joined:
    Feb 21, 2013
    Messages:
    20,477
    Likes Received:
    6,879
    I keep Linux File Systems for Windows by Paragon Software loaded. Works like da bomb :) Unobtrusive too.

    But that is because we do a fair mount if munging about with Raspberry Pi's :) Not that it is expensive, but you really shouldn't need it.
     
    #17 mark tomlinson, Aug 21, 2018
    Last edited: Aug 21, 2018
  18. mark tomlinson

    mark tomlinson ༼ つ ◕_ ◕ ༽つ
    Staff Member

    Joined:
    Feb 21, 2013
    Messages:
    20,477
    Likes Received:
    6,879
    Well, in a pinch you COULD pull the pi out and hook it up with an HDMI cable to your tv or monitor and get to the desktop, but that is a bit of a pain.
     
  19. mark tomlinson

    mark tomlinson ༼ つ ◕_ ◕ ༽つ
    Staff Member

    Joined:
    Feb 21, 2013
    Messages:
    20,477
    Likes Received:
    6,879
    Turns out I still have a slightly older version staged already. PM me if you want it. Updates will bring it up to current and once you get it networked you should be OK for it to handle the updates.
     
  20. Jerome Helbert

    Joined:
    Aug 19, 2017
    Messages:
    34
    Likes Received:
    12
    The saga continues... I still don't have this working. I really thought this was just the expected behavior for an R2 after the last OS update. I'm starting to believe I am the only one, and I don't understand why.

    Yep, that's what I used initially (there is a 10 day free trial, so I didn't have to buy it just for this.) I was eventually wanting to do more, so I just threw together an Ubuntu VM and mounted it there.

    So Robo does some strange things with the Pi... I could not get a monitor to display anything. I also hooked up a USB UART/TTL cable to the serial port and got nothing - even after modifying cmdline.txt and config.txt to enable it.

    As a sanity check I threw NOOBS onto a spare SD card and tossed that in. HDMI works perfectly, UART works perfectly, SSH works perfectly (once enabled via raspi_config)... So I know it's nothing hardware. My next plan to try and diff the Robo supplied image to the newly create Rasbian Lite image to see if I can find them blocking anything (maybe a script adding an iptables entry or something weird?)

    I might take you up on that. Comparing the factory fresh robo image to yours might find the differences faster than comparing to a stock rasbian image.
     

Share This Page