pkg/lib/ssh-show-default-key.sh
raw| 1 | #! /bin/sh |
| 2 | # SPDX-License-Identifier: LGPL-2.1-or-later |
| 3 | |
| 4 | set -euf |
| 5 | |
| 6 | # Print the name of default key, if any. |
| 7 | |
| 8 | for f in id_dsa id_ecdsa id_ecdsa_sk id_ed25519 id_ed25519_sk id_rsa; do |
| 9 | p=$HOME/.ssh/$f |
| 10 | if test -f "$p"; then |
| 11 | echo "$p" |
| 12 | if ! ssh-keygen -y -P "" -f "$p" >/dev/null 2>/dev/null; then |
| 13 | echo "encrypted" |
| 14 | fi |
| 15 | exit 0 |
| 16 | fi |
| 17 | done |