0

As i understand, an up to date installation of Raspbian is transferrable between different RPis. In my case this is a first gen, and a third gen RPi.

I would like to test configurations or new software on the first gen and, if successfull, transfer this "updated" installation to the productive RPi (3rd gen).

I would do this via cloning the two sdcards and booting the RPi.

However, some things are copied, which should be unique to the systems, e.g. hostname, ssh-keys and maybe other things i am forgetting.

How would i best go to automate setting these new after booting a cloned image ?

6
  • How about by writing a simple Python script to make your host name and ssh key changes? I think the bigger problem is where your going to get that data from. May 24, 2016 at 14:10
  • Optimally i would like some kind of input-possibility at restart after clonging. So if hostname/ssh-keys are missing/empty get a qeue to insert a new hostname and autogenerate ssh-keys.
    – kyze
    May 24, 2016 at 14:31
  • 1
    Try this raspberrypi.org/documentation/remote-access/ssh/passwordless.md and tell me if it fits your needs May 24, 2016 at 15:40
  • Thanks Mohammad, this put me on the right way, seems like "dpkg-reconfigure openssh-server" should be enough to autogenerate new ssh-keys. Im probably gonna write a short bash-script to do this as well as set a new hostname.
    – kyze
    May 25, 2016 at 7:46
  • are you expecting to use the ssh key for future logins? If so how do you plan on reviving it? Because I see no where in your question that talks about changing the login credentials. May 25, 2016 at 13:25

1 Answer 1

2

Yes you can do so (in most cases).

BTW There is no "first gen, and a third gen RPi" you should specify which model you are using by model.

There are some instances in which you cannot transfer - if the compiled program has hard coded perpheral addresses (1GB RAM models have different mapping) or there are differences between hardware e.g. The UART on Pi3.

You can clone cards, but this may require some massaging, depending on how it is setup. hostname should be unique, but this is not fatal, merely confusing.

You can re-generate ssh keys if you want unique sets, but there is no problem having identical keys on different machines. In fact I deliberately ensure that all my SD Cards have identical keys, which means I can swap them between Pi without remote ssh programs complaining about changed key/MAC pairs.

An alternative approach is to use ftp or similar to transfer programs, or better still rsync. This allows you to specify which things should not be transferred and selectively transfer data e.g. user directory or exclude /etc/hostname and /etc/hosts. If you want to try the rsync approach I can list scripts I use to synchronise Pi.

2
  • I have a RPi and a RPi3, that is what i meant with first and third gen. The hardware-differences are obvious, but should not matter for the software im using. I do know that the hostname and ssh-keys should be changed as its a different host, and that both can be manually changed. Is there anything else that should be unique to the host, that should be changed when cloning?
    – kyze
    May 25, 2016 at 7:24
  • 1
    @kyze Rpi could mean B+, B (which have separate dtb) plus some earlier revisions, not to mention the A+ and A. Probably only older users will have the earlier revisions, but you should be specific. This may not affect your particular case. As I mentioned above ssh is not necessarily an issue. If you change hostname manually you should also change /etc/hosts, although it would be better to do manual changes through raspi-config. There are no other issues unless you use static IP or specific hardware.
    – Milliways
    May 25, 2016 at 7:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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