10

I am not able to ssh into my pi. RPI is connected directly to my host PC.

I have set IP address of my host :----

sudo ifconfig eth0 192.168.0.204 netmask 255.255.255.0 up
sudo route add default gw 192.168.0.200

Pi have default IP in network interfaces file as :----

auto lo eth0
iface lo inet loopback
iface eth0 inet static
    address 192.168.0.202
    netmask 255.255.255.0
    gateway 192.168.0.200

if config comand on my PC :-----

ignite@ignite-desktop:~$ ifconfig
eth0      Link encap:Ethernet  HWaddr 6c:f0:49:f3:a6:1b  
          inet addr:192.168.0.204  Bcast:192.168.0.255  Mask:255.255.255.0
          inet6 addr: fe80::6ef0:49ff:fef3:a61b/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:681 errors:0 dropped:0 overruns:0 frame:0
          TX packets:208 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:43752 (43.7 KB)  TX bytes:33407 (33.4 KB)
          Interrupt:26 Base address:0x4000 

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:12 errors:0 dropped:0 overruns:0 frame:0
          TX packets:12 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:1012 (1.0 KB)  TX bytes:1012 (1.0 KB)

Ping is working for same host :----

ignite@ignite-desktop:~$ ping 192.168.0.204
PING 192.168.0.204 (192.168.0.204) 56(84) bytes of data.
64 bytes from 192.168.0.204: icmp_seq=1 ttl=64 time=0.026 ms
64 bytes from 192.168.0.204: icmp_seq=2 ttl=64 time=0.018 ms
64 bytes from 192.168.0.204: icmp_seq=3 ttl=64 time=0.017 ms
64 bytes from 192.168.0.204: icmp_seq=4 ttl=64 time=0.014 ms

Ping is working for pi from my host PC :----

ignite@ignite-desktop:~$ ping 192.168.0.202
PING 192.168.0.202 (192.168.0.202) 56(84) bytes of data.
64 bytes from 192.168.0.202: icmp_seq=1 ttl=64 time=0.530 ms
64 bytes from 192.168.0.202: icmp_seq=2 ttl=64 time=0.508 ms
64 bytes from 192.168.0.202: icmp_seq=3 ttl=64 time=0.464 ms
64 bytes from 192.168.0.202: icmp_seq=4 ttl=64 time=0.445 ms
64 bytes from 192.168.0.202: icmp_seq=5 ttl=64 time=0.434 ms

SSH is not working

ignite@ignite-desktop:~$ ssh pi@raspberrypi
ssh: Could not resolve hostname raspberrypi: Name or service not known

ignite@ignite-desktop:~$ ssh pi@192.168.0.202
Read from socket failed: Connection reset by peer

ignite@ignite-desktop:~$ ssh 192.168.0.202 -l pi
Read from socket failed: Connection reset by peer

Please suggest how to resolve it ?

edit :---
ssh -vvv pi@192.168.0.202 ---> output is

ignite@ignite-desktop:~$ ssh -vvv pi@192.168.0.202
OpenSSH_5.1p1 Debian-6ubuntu2, OpenSSL 0.9.8g 19 Oct 2007
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug2: ssh_connect: needpriv 0
debug1: Connecting to 192.168.0.202 [192.168.0.202] port 22.
debug1: Connection established.
debug1: identity file /home/ignite/.ssh/identity type -1
debug1: identity file /home/ignite/.ssh/id_rsa type -1
debug1: identity file /home/ignite/.ssh/id_dsa type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_6.0p1 Debian-2
debug1: match: OpenSSH_6.0p1 Debian-2 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.1p1 Debian-6ubuntu2
debug2: fd 3 setting O_NONBLOCK
debug1: SSH2_MSG_KEXINIT sent
Read from socket failed: Connection reset by peer
  • 1
    Have you checked that the ssh daemon is running? – codey Apr 19 '13 at 14:45
  • actually i do not have an HDMI screen & was using my remote desktop computer to logon into pi using ssh. Now how can i check it out ? – Allan Apr 19 '13 at 17:18
  • ps aux | grep sshd – codey Apr 22 '13 at 0:38
  • If sshd is running, the output will show the sshd process(es). Besides the "grep sshd" that we just ran, of course. – codey Apr 22 '13 at 0:46
5

I had same issue with newly installed raspbian and the problem was with server side ssh host keys.

These keys are not generated on image for the reasons that each device must have different ssh keys and during first boot are these keys generated automatically.

My problem was that probably during generating these keys I disconnect supply, they was wrong with zero size.

Solution is to regenerate ssh server side host keys:

rm /etc/ssh/ssh_host_*
dpkg-reconfigure openssh-server

https://wiki.debian.org/SSH#Regenerating_host_keys

  • 2
    how should one regenerate ssh server side host keys (dpkg-reconfigure openssh-server) if they cannot login in the first place? – Hayri Uğur Koltuk Apr 18 '18 at 19:16
  • Exactly @HayriUğurKoltuk I'm on a mac, how could I do that? – clearlight Dec 20 '18 at 5:39
4

Reason for issue and fix

Without special programs, you cannot ssh into the Pi using its host name. For LAN networks, ping the host. Once you have the IP, write it down. Then write into the terminal:

ssh pi@this_is_the_ip

and you should be able to log in.

If you want to access the Pi from outside of your home network, you must port forward your router. In fact, there is a stack exchange question on how to do this.

Assuming that you still want to use a nice name for your Pi, there is one option that will work both within your network and without it.

DNSDynamic

This software allows you to set up a domain name for your pi.

  1. Go to their website and set up a domain name and an account.

  2. Install ddclient on your Pi.

    sudo apt-get install ddclient 
    

    And then edit the config settings.

    sudo nano /etc/ddclient.conf
    

    Finally, change the file to the following:

# /etc/ddclient.conf

daemon=600

timeout=10

ssl=yes

protocol=dyndns2

use=web, web=myip.dnsdynamic.com #Enter your URL here

server=www.dnsdynamic.org

login=x@gmail.com  #userid for dnsdynamic.com

password='xxxx'      #password for the same put inside quotes

x.dnsdynamic.com  #the domain name you created

Assuming that you want this to auto start every time your computer wakes up, enter the following into the terminal.

sudo nano /etc/rc.local

Add the following command before exit 0(which is the last line)

sudo /usr/sbin/ddclient -daemon 600 -syslog

Lastly, you must still portforward.

Hopefully this is helpful. Ask questions in the comment section below.

  • Actually i compiled & installed latest openssl to my target RPi . Now ssh is not working for me Does ssh depends upon openssl ? – Allan Apr 19 '13 at 17:20
  • SSL (secure sockets layer) is not needed to run SSH. It may actually be the issue in this setup. But, please try using the Pi's local IP instead of its hostname. – xxmbabanexx Apr 19 '13 at 17:47
  • i have posted o/p for -----> ssh -vvv pi@192.168.0.202 ---> can you suggest what is the problem – Allan Apr 20 '13 at 2:58
  • i regenerated keys on my host & target .. removed known host file from ~/.ssh ... it worked ... – Allan Apr 20 '13 at 3:48
  • remove all file from :--- /etc/ssh ----> except shh_config ---> and changed ssh config as per this link ---> blog.harshadura.net/2012/01/… – Allan Apr 28 '13 at 11:12
0

You can have a look at my answer for this questions.

How to get the Raspberry Pi's IP address for SSH

Another possibility I didn't mention there is to buy a domain (it's very cheap) and play with the DNS. I bought the domain aasgard.info for 0.99 cents and assigned name ygdrasill.aasgard.info to an internal address (192.168.1.141 in this case). Then you need to set the default domain as the domain name you bought and voila' :)

I must confess that after having spent all the time to set up the domain I realized that using /etc/hosts file or avahi was much much easier :)

0

Are you sure that you've started an SSH server on your Raspberry Pi? Just because you can ping it doesn't mean it's running an SSH server. Try sshd for a light SSH server.

0

Enable SSH

As of the November 2016 release, Raspbian has the SSH server disabled by default.

It can be enabled manually from Terminal:

sudo raspi-config
Select Interfacing Options
Navigate to and select SSH
Choose Yes
Select Ok
Choose Finish

or

Launch Raspberry Pi Configuration from the Preferences menu
Navigate to the Interfaces tab
Select Enabled next to SSH
Click OK

Alternatively, use systemctl to start the service

sudo systemctl enable ssh
sudo systemctl start ssh
-1

The SSH connectivity is by default DISABLED in latest raspberry pi. The RPi which are released in/after November 2016.

The steps are: 1) Write raspbian image to SD card. 2) create a ssh file without extension. 3) copy that ssh file to SD card where your image is written. 4) Finally wou will be able to SSH your raspberry pi.

For more details watch this video : https://www.youtube.com/watch?v=zKT6bTESlLs

  • 2
    Welcome to Raspberry Pi! Please take the tour and visit the helpcenter to see how things work here. Note that this question is from 2013. Back then the issue you describe has not been an issue at all... – Ghanima Jul 24 '17 at 17:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.