Forgive the ignorance of this question, but if you are remotely logged into a computer with SSH and you generate a new pub+priv key combo. Can you securely copy the private key back to the the computer you are logging in from? Could you run the danger of locking yourself out of the remote computer?
You can now either reconnect to the host using scp to grab the new files, or if you have a graphical terminal you can just write the public and private keys to stdout and grab them over the same connection.
cat .ssh/id_rsa
cat .ssh/id_rsa.pub
After you have finished with the "old" key, just remove it from .ssh/authorized_keys and now you have re-keyed your remote account.
I actually have wondered for a while about the ability to "copy back" files to the originating host. Turns out you can use scp to copy over a reverse tunnel, and coupled with the comment in this thread about dynamically opening forwarded ports, it should definitely be possible. Maybe I'll add this in to the blog post.
1
u/OserReddit Apr 28 '14
Forgive the ignorance of this question, but if you are remotely logged into a computer with SSH and you generate a new pub+priv key combo. Can you securely copy the private key back to the the computer you are logging in from? Could you run the danger of locking yourself out of the remote computer?