Results 1 to 5 of 5

Thread: migrating ssh keys intra-machine

  1. #1
    Join Date
    Jan 2020
    Beans
    3

    migrating ssh keys intra-machine

    Desire to migrate (copy) ssh keys to another op-sys on the same machine. More specifically, have Lubuntu 18.04 on partition 1. Then installed Debian 9 on partition 2 and Debian 10 on partition 3. Same computer, same hostname, same domainname, same login name, same passwords. Have copied Lubuntu /home/me/.ssh/* into /home/me/.ssh of other partitions. Desire to ssh to<>from other machines around the LAN without regard to what op-sys is active on this machine. Do not mind presenting password for login, but having to wipe the known_hosts is becoming a major bother.

    Have stumbled/searched around the web on this issue but - rather surprisingly - found nothing that seems to address it. - shu
    Last edited by shu2462; January 8th, 2020 at 05:07 AM.

  2. #2
    Join Date
    Nov 2008
    Location
    Metro Boston
    Beans
    14,804
    Distro
    Kubuntu 19.10 Eoan Ermine

    Re: migrating ssh keys intra-machine

    Usually having the same .ssh directory is all you need. Are you getting errors?
    If you ask for help, do not abandon your request. Please have the courtesy to check for responses and thank the people who helped you.

    Blog · Linode System Administration Guides · Android Apps for Ubuntu Users

  3. #3
    Join Date
    Jan 2020
    Beans
    3

    Re: migrating ssh keys intra-machine

    Thanks for the reply, Sensei.

    //charlie is the machine at issue. //bravo is my Win10 principal machine, running WSL bash.
    Desired outcome is ssh from //bravo to //charlie regardless of what op-sys is running on //charlie.

    booted //charlie to well established install of Lubuntu 18.04
    then at //bravo:
    $ rm ~/.ssh/known_hosts ............#to start clean
    $ ssh charlie .............#ordinary first-time ssh procedure, no problem

    boot //charlie to fresh install of Debian 9.9
    [create mount point; mount Lubuntu partition; copy Lubuntu/home/rick/.ssh/* to Debian/home/rick/.ssh]

    back at //bravo:
    rick@BRAVO:~$ ssh charlie
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@
    @ 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
    SHA256:BbqaAgZE1fBiMp+XgO5tlftwNIxg97pkXkN1pPikv+s .
    Please contact your system administrator.
    Add correct host key in /home/rick/.ssh/known_hosts to get rid of this message.
    Offending ECDSA key in /home/rick/.ssh/known_hosts:1
    remove with:
    ssh-keygen -f "/home/rick/.ssh/known_hosts" -R "charlie"
    ECDSA host key for charlie has changed and you have requested strict checking.
    Host key verification failed.
    rick@BRAVO:~$

    To clear the error I can either
    do the suggested "ssh-keygen -f ...." or simply
    rm ~/.ssh/known_hosts.

  4. #4
    Join Date
    Nov 2007
    Location
    London, England
    Beans
    6,920
    Distro
    Xubuntu 19.10 Eoan Ermine

    Re: migrating ssh keys intra-machine

    I think maybe the host id is in /etc/ssh. You could try copying these across, but make sure you keep the originals to restore if it doesn't work.

  5. #5
    Join Date
    Jan 2020
    Beans
    3

    Re: migrating ssh keys intra-machine

    Indeed! Fixdit!

    Per usual practice, made a safety fallback copy at //charlie
    $ sudo cp -r /etc/ssh /etc/ssh.af ................#(=as found)

    Two config files in the new Debian /etc/ssh were different from those in the established Lubuntu partition. Those I left intact. Copied from the established Lubuntu partition to the new Debian partition
    ..all /etc/ssh/ssh_host*
    ..an /etc/ssh/ssh_import_id ............#for no password login to the Synology NAS

    Done, and thank you. -shu

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
  •