SSH Pubkey Finder is a Bash script that allows you to retrieve all the authorized SSH public keys on a Linux system.
- Retrieves all users on the system.
- Lists authorized SSH public keys for each user.
- Allows specifying a user’s group.
Clone the GitHub repository:
git clone https://github.com/ISC-HEI/ssh-pubkey-finder.git
cd ssh-pubkey-finderYou can add the official repository and install the package directly:
- Add the repository to your system:
echo "deb [trusted=yes] https://apt.chezmoicamarche.ch/ssh-pubkey-finder/repo stable main" | sudo tee /etc/apt/sources.list.d/ssh-pubkey-finder.list- Update your package lists and install the package:
sudo apt update
sudo apt install ssh-pubkey-finder- Run the script:
ssh-pubkey-finder -v
# Output: 0.3.0Note: Installing via apt makes the script available system-wide, so you don’t need to be in the repository folder to run it.
To install this script using Snap, you can run:
./build-snap.shThis will create a .snap file in the dist folder. Then install it like that:
sudo snap install ./dist/ssh-pubkey-finder_0.3.0_amd64.snap --classic --dangerousIf you want to publish this script, you can check the corresponding README.md
Run the script using the following command:
If the script is installed system-wide:
ssh-pubkey-finderIf running directly from the cloned repository:
# Make sure the script is executable (normally it is)
chmod +x ssh-pubkeys-finder
# Execute the script
./ssh-pubkeys-finder| Argument | Description | Params |
|---|---|---|
| -h | Show help | X |
| -v | Show the current version | X |
| -u USER | Check only for the specified user | USER: the user to check |
Here you can see an example of output with no argument:
admin@mypc:~/$ ./ssh-pubkey-finder
Permission denied, root may have some public keys
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAICBeVf+bmAsL6O0li173PA8dw4qSWwU1v3WegXGB26IV adrien
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOgJnqfqwBihTBLfBn0+SEr0W1oWz13mUFFZ56XSYoC8 adrienadmin@mypc:~/$ sudo ./ssh-pubkey-finder
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAICBeVf+bmAsL6O0li173PA8dw4qSWwU1v3WegXGB26IV adrien, local
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOgJnqfqwBihTBLfBn0+SEr0W1oWz13mUFFZ56XSYoC8 adrienHere you can see an example with the specified user
admin@mypc:~/$ sudo ./ssh-pubkey-finder -u adrien
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAICBeVf+bmAsL6O0li173PA8dw4qSWwU1v3WegXGB26IV adrien
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOgJnqfqwBihTBLfBn0+SEr0W1oWz13mUFFZ56XSYoC8 adrien
The current License is Apache version 2.0, you can see it in the LICENSE file.