So what has happenend, is that I have a Ubuntu 14 server. I have my SSH key uploaded to the server, and a password. I only have one user; root. The problem is now, I formatted the computer on which I had the SSH key. Is it in any way possible to get access to the server, without losing any data?
32 Answers
The SSH key uploaded to the remote server is the public key, which is one of two parts of the actual "SSH Key". It is designed to be 'publicly' disclosed to remote servers, as you need the corresponding private key which is stored on your computer to work with the connection. (An analogous example is PGP encryption which works in a similar way - the PGP public key can be used to encrypt data, but the PGP private key is needed to decrypt the information and use it. In the same way, SSH needs you to have the private key that corresponds to the public key in order to do key-based authentication.)
If you formatted your system, lost your private key, and have written data to the disk since then, you likely cannot recover the SSH private key.
Check with the remote server provider, and see if they have a serial console to access the system. If it's a VPS they probably have such a mechanism available through a control panel. Create a new SSH key on your computer, upload the private key to the server through the serial console, remove the old private key, and then connect normally.
If SSH on the server side allows key authentication only and the private key on the client (your) side it lost, you need to contact the system administrators, connect a monitor to the machine (depending on your possibilities to access the server).
If you get a password: prompt when you run ssh root@[ip], then you should try a password you might have set on the server.