Results 1 to 7 of 7

Thread: BASH ssh problem - changing SD card OS in Rpi causes this

  1. #1
    Join Date
    Oct 2008
    Beans
    49

    BASH ssh problem - changing SD card OS in Rpi causes this

    Now i got to see the hidden files with ls -a

    but I can't seem to get into root to find the files that need changing.

    Feel very nervous about this, don't want to nuke the OS !

    Code:
    tim@tim-A880G:~$ ssh -l pi 192.168.1.105 
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 
    @    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @ 
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 
    IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY! 
    Someone could be eavesdropping on you right now (man-in-the-middle attack)! 
    It is also possible that a host key has just been changed. 
    The fingerprint for the ECDSA key sent by the remote host is 
    b5:a2:ef:bf:83:61:ae:c0:b2:f4:59:0e:b3:12:8f:ff. 
    Please contact your system administrator. 
    Add correct host key in /home/tim/.ssh/known_hosts to get rid of this message. 
    Offending ECDSA key in /home/tim/.ssh/known_hosts:6 
      remove with: ssh-keygen -f "/home/tim/.ssh/known_hosts" -R 192.168.1.105 
    ECDSA host key for 192.168.1.105 has changed and you have requested strict checking. 
    Host key verification failed.
    Any thoughts anyone ?

    A puzzled,

    Tim

  2. #2
    Join Date
    Oct 2009
    Location
    Elgin, IL USA
    Beans
    2,533
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: BASH ssh problem - changing SD card OS in Rpi causes this - HELP !

    If by Rpi you mean a Raspberry Pi (or any computer with sshd) the files you want to replicate on your own computers are the "key" files is /etc/ssh. Otherwise those files are uniquely generated the first time you run Raspbian.

    You probably need to use sudo to cp those files into place, whether you do that directly to the SD card, or scp them over in your username and then use sudo cp to copy them into /etc/ssh.
    Code:
    efflandt@raspberrypi ~ $ ls /etc/ssh
    moduli       ssh_host_dsa_key      ssh_host_ecdsa_key.pub
    ssh_config   ssh_host_dsa_key.pub  ssh_host_rsa_key
    sshd_config  ssh_host_ecdsa_key    ssh_host_rsa_key.pub
    On thing you may want to do is install avahi-browser on your Rpi's. Set a different hostname in /etc/hostname and /etc/hosts of each SD card and then you can access them from Ubunu (or Apple or Windows with Bonjour installed) with their hostname.local
    Code:
    efflandt@XPS8100-1204:~$ tracepath -n raspberrypi.local
     1:  172.16.0.50                                           0.104ms pmtu 1500
     1:  172.16.0.102                                         46.849ms reached
     1:  172.16.0.102                                         23.246ms reached
         Resume: pmtu 1500 hops 1 back 64
    i5 650 3.2 GHz, 8 GB, nvidia GTX 550 Ti 32" 1080p | i7-4700, 8 GB, Intel HD 4600/nvidia GTX 765M 15.6" 1080p | etc.

  3. #3
    Join Date
    Oct 2008
    Beans
    49

    Re: BASH ssh problem - changing SD card OS in Rpi causes this

    I think I needed to explain the set up more...sorry I did not in the first post.

    I use Ubuntu 12.04 as the sh to gain access to the RPi.

    I don't think its the RPi's fault, just the way Ubuntu works.

    I dont know how access the root directory of Ubuntu and then /etc etc

    I'm stuck in the home directory.

    Hope that makes sense.

    Lack of Bash knowledge ins my proble. (one of them *LOL*)

    Many thanks for responding


    Tim
    Last edited by Tim036; March 24th, 2013 at 11:33 AM.

  4. #4
    Join Date
    Sep 2006
    Beans
    7,247
    Distro
    Lubuntu Development Release

    key fingerprints

    If you changed the OS on the SD card or the SD card itself, the keys in /etc/ssh/ will have changed unless you copied the old ones over onto the new chip or system. If you are confident that the key "b5:a2:ef:bf:83:61:ae:c0:b2:f4:59:0e:b3:12:8f: ff" is the right one, then you can follow the instructions given in the error message to remove the old fingerprint from your local file:

    Code:
    ssh-keygen -f "/home/tim/.ssh/known_hosts" -R 192.168.1.105
    Once you have logged into your server (Rpi) you can double check the key fingerprint with ssh-keygen.

    Code:
    ssh-keygen -lf /etc/ssh/ssh_host_ecdsa_key

  5. #5
    Join Date
    Oct 2008
    Beans
    49

    Re: BASH ssh problem - changing SD card OS in Rpi causes this

    Many many thanks ! That is Brillian.

    I gave it a poke and did this:-

    At my normal Terminal prompt:-

    su
    and at the password prompt I entered my password

    cd /

    cd /root

    entered the :-

    ssh-keygen -f "/home/tim/.ssh/known_hosts" -R 192.168.1.105

    (not knowing how to get back to my normal prompt, I closed the terminal and restarted it.

    and lo ! It worked !

    So in the root directory I wrote a little script with 'nano' editor:-

    Code:
    #!  /bin/sh
    
    #  chmod a+x ssh_fix
    
    #For whenh the Raspian SD card is changed and problem logging occurs
    
    ssh-keygen -f "/home/tim/.ssh/known_hosts" -R 192.168.1.105
    So if anyone, like me, doesn't know the difference between sudo and su, has the same problem. That the fix that worked for me !

    Silly details often bring me to my knees when trying to use Linux !

    So many many thanks to the members of this Forum that stop me tearing more of my hair out ! ! !



    Tim

  6. #6
    Join Date
    Sep 2006
    Beans
    7,247
    Distro
    Lubuntu Development Release

    host keys

    A way to avoid the problem in the first place is to backup the following files from your old system and transfer them to your new card or new system:

    Code:
    /etc/ssh/ssh_host_dsa_key
    /etc/ssh/ssh_host_dsa_key.pub
    /etc/ssh/ssh_host_ecdsa_key
    /etc/ssh/ssh_host_ecdsa_key.pub
    /etc/ssh/ssh_host_rsa_key
    /etc/ssh/ssh_host_rsa_key.pub
    The utility tar should do the job nicely, but you can also use plain sudo cp.

  7. #7
    Join Date
    Oct 2008
    Beans
    49

    Re: BASH ssh problem - changing SD card OS in Rpi causes this

    PS

    On the RPi

    Code:
    ssh-keygen -lf /etc/ssh/ssh_host_ecdsa_key

    works well but to get to root on a RPi

    you may need this

    Code:
    sudo passwd root
    once you have set your password

    su gets you to root

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •