rohanlele
Posts: 6
Joined: Fri Apr 27, 2018 3:58 am

Cannot ssh to the Pi using PuTTy within router network

Fri Apr 27, 2018 5:05 am

Hello,
I am using latest raspbian image on my Pi B+. I have set a static IP for my Pi.
I tried enabling ssh service on the Pi.
I also generated new dsa/rsa keys and saved them in /etc/ssh.

I still cannot connect to my Pi using SSH through PuTTy. I get an error: Software caused connection abort.

Any solution to this?

Thanks,
Rohan L

Edwardweiwei
Posts: 9
Joined: Thu Jul 14, 2016 9:16 am

Re: Cannot ssh to the Pi using PuTTy within router network

Fri Apr 27, 2018 9:01 am

Hello Rohanlele, did you try to make a new blank file naming "ssh" in your SDCard root directory :Boot ??

User avatar
B.Goode
Posts: 10356
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: Cannot ssh to the Pi using PuTTy within router network

Fri Apr 27, 2018 9:50 am

I have set a static IP for my Pi.

( ... )

I still cannot connect to my Pi using SSH through PuTTy. I get an error: Software caused connection abort.
Many initial difficulties with ssh turn out to be attempting to make a connection to the wrong device on the network.

How did you select the IP address that you have assigned to your RPi? Is it possible that it is being used by another device on your network?

Although in the long term you may find it convenient to work with a static IP address, have you tried leaving the IP address configuration untouched, as installed by the Operating System, and allowing the DHCP server on your network to allocate an appropriate IP address 'automagically?'

If you need a predictable IP address using the configuration tools for your DHCP server to map a known address to the Mac address of your RPi is a better solution in my opinion.

rohanlele
Posts: 6
Joined: Fri Apr 27, 2018 3:58 am

Re: Cannot ssh to the Pi using PuTTy within router network

Fri Apr 27, 2018 6:37 pm

Edwardweiwei wrote:
Fri Apr 27, 2018 9:01 am
Hello Rohanlele, did you try to make a new blank file naming "ssh" in your SDCard root directory :Boot ??
Hi,
I haven't tried that yet. Will give it a try. Thanks.

User avatar
B.Goode
Posts: 10356
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: Cannot ssh to the Pi using PuTTy within router network

Fri Apr 27, 2018 6:43 pm

rohanlele wrote:
Fri Apr 27, 2018 6:37 pm
Edwardweiwei wrote:
Fri Apr 27, 2018 9:01 am
Hello Rohanlele, did you try to make a new blank file naming "ssh" in your SDCard root directory :Boot ??
Hi,
I haven't tried that yet. Will give it a try. Thanks.

You said in your initial post:
I tried enabling ssh service on the Pi.
How did you do that? If you have a monitor and keyboard on the RPi and used the raspi-config utility to enable the ssh server/daemon/ listener you don't need to do it again.

If you do have the means to work directly on the RPi itself, it's easy to check by trying

Code: Select all

ssh pi@localhost

rohanlele
Posts: 6
Joined: Fri Apr 27, 2018 3:58 am

Re: Cannot ssh to the Pi using PuTTy within router network

Fri Apr 27, 2018 6:55 pm

B.Goode wrote:
Fri Apr 27, 2018 6:43 pm
rohanlele wrote:
Fri Apr 27, 2018 6:37 pm
Edwardweiwei wrote:
Fri Apr 27, 2018 9:01 am
Hello Rohanlele, did you try to make a new blank file naming "ssh" in your SDCard root directory :Boot ??
Hi,
I haven't tried that yet. Will give it a try. Thanks.

You said in your initial post:
I tried enabling ssh service on the Pi.
How did you do that? If you have a monitor and keyboard on the RPi and used the raspi-config utility to enable the ssh server/daemon/ listener you don't need to do it again.

If you do have the means to work directly on the RPi itself, it's easy to check by trying

Code: Select all

ssh pi@localhost
I am using the serial port to access the terminal. I do not have a keyboard and monitor. I used sudo raspi-config to enable the SSH server. I am not sure if this independent of creating and naming a blank file 'ssh' in the /boot directory.
Thanks.

User avatar
B.Goode
Posts: 10356
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: Cannot ssh to the Pi using PuTTy within router network

Fri Apr 27, 2018 7:09 pm

I am using the serial port to access the terminal. I do not have a keyboard and monitor. I used sudo raspi-config to enable the SSH server. I am not sure if this independent of creating and naming a blank file 'ssh' in the /boot directory.
The important thing is that you have some means of interacting with the OS on the RPi, you are not working 'blind' which is more challenging.

Raspi-config and the ssh marker file should have the same effect.

If ssh has been enabled then you will be able to get a 'loopback' login by trying ssh pi@localhost. That will fail if you have not enabled ssh correctly.

You can also check the effective IP address of the RPi with various commands such as ip addr

rohanlele
Posts: 6
Joined: Fri Apr 27, 2018 3:58 am

Re: Cannot ssh to the Pi using PuTTy within router network

Fri Apr 27, 2018 7:14 pm

B.Goode wrote:
Fri Apr 27, 2018 7:09 pm
I am using the serial port to access the terminal. I do not have a keyboard and monitor. I used sudo raspi-config to enable the SSH server. I am not sure if this independent of creating and naming a blank file 'ssh' in the /boot directory.
The important thing is that you have some means of interacting with the OS on the RPi, you are not working 'blind' which is more challenging.

Raspi-config and the ssh marker file should have the same effect.

If ssh has been enabled then you will be able to get a 'loopback' login by trying ssh pi@localhost. That will fail if you have not enabled ssh correctly.

You can also check the effective IP address of the RPi with various commands such as ip addr
Sure, Thanks a lot. Will give it a try and see if SSH is really enabled.

User avatar
HawaiianPi
Posts: 5886
Joined: Mon Apr 08, 2013 4:53 am
Location: Aloha, Oregon USA

Re: Cannot ssh to the Pi using PuTTy within router network

Fri Apr 27, 2018 8:57 pm

rohanlele wrote:
Fri Apr 27, 2018 5:05 am
Hello,
I am using latest raspbian image on my Pi B+. I have set a static IP for my Pi.
How (and why) did you do that?

In my experience setting a static IP is usually the cause of connection problems. I suggest you start over with an unmolested Raspbian install and use your serial console connection to find the DHCP assigned IP of your Pi.

This is the procedure I use for setting up headless boot with SSH and wireless network. It works with Raspbian Jessie or Stretch, Desktop or Lite, and with the built-in WiFi on the Pi3B(+) & Pi Zero W, or a Raspbian compatible USB WiFi dongle on other models. Everything is done before you boot, and can be done on a Windows or Mac computer which only has access to the small FAT32 "boot" partition of a Raspbian imaged SD card.
  1. Grab the latest Raspbian image from https://www.raspberrypi.org/downloads/raspbian/
  2. Grab the Etcher software from https://etcher.io/
  3. Install Etcher and use it to write the Raspbian image to your SD card.
    • You don't need to extract the image or format the card prior to writing.
    • Just run Etcher, choose the Raspbian .zip you downloaded, pick your SD card and write.
    • If you have trouble, verify the SHA256 checksum of the download.
  4. Remove and reinsert the SD card so that your Windows or Mac PC can see the small FAT32 partition on the card (labelled "boot").
    • If you get a message telling you the card must be formatted, cancel it.
  5. On that small FAT32 partition, create a file with the name ssh (or ssh.txt). It can be empty, the contents don't matter.
  6. To connect to a wireless network, create another file on the card called wpa_supplicant.conf, which has the following inside:

    Code: Select all

    ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
    update_config=1
    country=US
    
    network={
         ssid="Your network name/SSID"
         psk="Your WPA/WPA2 security key"
         key_mgmt=WPA-PSK
    }
    • Edit country=, ssid= and psk= with your information and save the file.
    • Use the 2 letter country abbreviation in CAPS.
    • Use a pure text editor, not a word processor, to edit the wpa_supplicant.conf file.
  7. Make sure that both files are in the main directory of the small FAT32 partition, not in any folder.
  8. Safely eject the card from your PC and use it to boot the Pi.
If Raspbian finds an ssh file it will enable SSH and delete the file. If it finds a wpa_supplicant.conf file, it will move it to its correct location and connect to your wireless network. Give your Pi some time to boot and connect to your network (the first boot always takes longer), then you should be able to SSH into the Pi and configure it how you like.

If you have a Zeroconf network service installed (Apple's iTunes, Bonjour or Quicktime install Zeroconf), you can SSH into pi@raspberrypi.local (provided you don't have any other Pi computers on your network with the same default hostname). Otherwise you must SSH into your Pi's IP address, which you can find by logging into your router and checking the list of connected clients, or using a network scanner app (like Fing for smartphones) to find your Pi on your network (or in your case you could use the serial console connection).

If you really want a fixed IP, the best way to do that is to reserve the IP address in your router's DHCP configuration. Since the IP is reserved by MAC address your Pi will always get the same IP with no OS configuration (and regardless of OS).
My mind is like a browser. 27 tabs are open, 9 aren't responding,
lots of pop-ups...and where is that annoying music coming from?

rohanlele
Posts: 6
Joined: Fri Apr 27, 2018 3:58 am

Re: Cannot ssh to the Pi using PuTTy within router network

Mon Apr 30, 2018 3:04 pm

HawaiianPi wrote:
Fri Apr 27, 2018 8:57 pm
rohanlele wrote:
Fri Apr 27, 2018 5:05 am
Hello,
I am using latest raspbian image on my Pi B+. I have set a static IP for my Pi.
How (and why) did you do that?

In my experience setting a static IP is usually the cause of connection problems. I suggest you start over with an unmolested Raspbian install and use your serial console connection to find the DHCP assigned IP of your Pi.

This is the procedure I use for setting up headless boot with SSH and wireless network. It works with Raspbian Jessie or Stretch, Desktop or Lite, and with the built-in WiFi on the Pi3B(+) & Pi Zero W, or a Raspbian compatible USB WiFi dongle on other models. Everything is done before you boot, and can be done on a Windows or Mac computer which only has access to the small FAT32 "boot" partition of a Raspbian imaged SD card.
  1. Grab the latest Raspbian image from https://www.raspberrypi.org/downloads/raspbian/
  2. Grab the Etcher software from https://etcher.io/
  3. Install Etcher and use it to write the Raspbian image to your SD card.
    • You don't need to extract the image or format the card prior to writing.
    • Just run Etcher, choose the Raspbian .zip you downloaded, pick your SD card and write.
    • If you have trouble, verify the SHA256 checksum of the download.
  4. Remove and reinsert the SD card so that your Windows or Mac PC can see the small FAT32 partition on the card (labelled "boot").
    • If you get a message telling you the card must be formatted, cancel it.
  5. On that small FAT32 partition, create a file with the name ssh (or ssh.txt). It can be empty, the contents don't matter.
  6. To connect to a wireless network, create another file on the card called wpa_supplicant.conf, which has the following inside:

    Code: Select all

    ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
    update_config=1
    country=US
    
    network={
         ssid="Your network name/SSID"
         psk="Your WPA/WPA2 security key"
         key_mgmt=WPA-PSK
    }
    • Edit country=, ssid= and psk= with your information and save the file.
    • Use the 2 letter country abbreviation in CAPS.
    • Use a pure text editor, not a word processor, to edit the wpa_supplicant.conf file.
  7. Make sure that both files are in the main directory of the small FAT32 partition, not in any folder.
  8. Safely eject the card from your PC and use it to boot the Pi.
If Raspbian finds an ssh file it will enable SSH and delete the file. If it finds a wpa_supplicant.conf file, it will move it to its correct location and connect to your wireless network. Give your Pi some time to boot and connect to your network (the first boot always takes longer), then you should be able to SSH into the Pi and configure it how you like.

If you have a Zeroconf network service installed (Apple's iTunes, Bonjour or Quicktime install Zeroconf), you can SSH into pi@raspberrypi.local (provided you don't have any other Pi computers on your network with the same default hostname). Otherwise you must SSH into your Pi's IP address, which you can find by logging into your router and checking the list of connected clients, or using a network scanner app (like Fing for smartphones) to find your Pi on your network (or in your case you could use the serial console connection).

If you really want a fixed IP, the best way to do that is to reserve the IP address in your router's DHCP configuration. Since the IP is reserved by MAC address your Pi will always get the same IP with no OS configuration (and regardless of OS).
Hi,
Thanks a lot. This worked and now I can SSH to the Pi over wired ethernet.
However, SSH connection times out after sometime if there is inactivity. Is this common for the Raspberry pi?

Also, do you have any suggestions to have a remote connection to the Pi's graphical desktop.

Thanks,
Rohan

User avatar
B.Goode
Posts: 10356
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: Cannot ssh to the Pi using PuTTy within router network

Mon Apr 30, 2018 4:46 pm

do you have any suggestions to have a remote connection to the Pi's graphical desktop.


https://www.raspberrypi.org/documentati ... /README.md

Return to “Troubleshooting”