If you are a system administrator using Ubuntu Linux, you likely use the SSH (Secure Shell) command to remotely connect to dozens of different web servers. If you forget the IP address of a specific server you connected to last month, you might assume you are out of luck.
However, every time you successfully connect to a new SSH server, Ubuntu logs the server’s exact IP address and cryptographic signature into a hidden file called “known_hosts” to protect you from future man-in-the-middle attacks. You can safely extract this entire log file to view your complete server connection history.
How to Safely Extract the Ubuntu SSH Known Hosts File
You must navigate into the hidden `.ssh` directory and read the cryptographic log.
- Open your Terminal application (Ctrl + Alt + T).
- Ensure you are in your home directory by typing
cd ~and pressing Enter. - The SSH folder is hidden. To enter it, type:
cd .ssh - Type
lsand press Enter. You should see a file named known_hosts. - To extract the contents of the file and display them on your screen, use the `cat` command:
cat known_hosts - Press Enter.
The terminal will output a wall of highly technical cryptographic keys. However, look at the very beginning of every single line. The first item on each line is the exact IP address or domain name (e.g., 192.168.1.50 or github.com) of every server you have successfully connected to. You can easily scroll through this list to recover the lost IP address of your missing web server.