I am making a new Ubuntu machine as a server, which is supposed to replace an old one with older software.
My question is:
Is it possible to transfer/copy the credentials (in terms of SSH) of the old machine/server to the new machine?
My goal is such that the new machine should supplant the old one and be seen by others as the same machine when using SSH. In other words, I want to ease the upgrading of my network without having to reset SSH-based credentials if one server (and in particular its OS) is replaced.
Thanks
-- Update --
My specific goal was to transfer credentials for the server only, but I do use ssh to replace password based login sometimes, and the suggestions on the client/server connections are also very helpful.
The server credentials —that make up the "fingerprint" SSH clients bleat on about if they are incorrect— are actually just keypairs defined in
/etc/ssh/sshd_config
:Copy these files over (with their .pub variants), replicate a similar config pointing to them, reload
sshd
, and things should Just Work™.You'll also want to copy over client pubkeys (that people have uploaded to their
~/.ssh/authorized_keys
but as this is an upgrade, you're probably copying those anyway.And obviously the fingerprint also relies on the hostname being the same but it sounds like that's what you're doing anyway.
You must append the contents of
$HOME/.ssh/id_rsa.pub
to the other server's$HOME/.ssh/authorized_keys
. Luckily, there is a binary for that;ssh-copy-id
. Its usage is simple:ssh-copy-id -i .ssh/id_rsa.pub <user>@<remote.server>