39 lines
1.3 KiB
Bash
Executable File
39 lines
1.3 KiB
Bash
Executable File
#!/bin/sh
|
|
#
|
|
# SSH key indicator for ssh-agent
|
|
#
|
|
# Copyright (C) 2012 Mike Gerwitz
|
|
#
|
|
# This program is free software: you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
# (at your option) any later version.
|
|
#
|
|
# This program is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
#
|
|
# The rationale behind the coloring is simply that, without the key in the
|
|
# agent, I will be prompted for passwords for (depending on location)
|
|
# numerous boxes---a frustrating task. However, the reverse coloring would
|
|
# be equally applicable---remote systems are more vulnerable if someone has
|
|
# access to your agent. I take precautions to make the latter incredibly
|
|
# difficult.
|
|
##
|
|
|
|
. ~/.ssh/.agent
|
|
keys="$( ssh-add -L | grep ^ssh | wc -l )"
|
|
|
|
# green if keys exist in agent, otherwise yellow
|
|
color=g
|
|
[ "$keys" -eq 0 ] && color=y
|
|
|
|
# red if agent is not started
|
|
[ -z "$SSH_AGENT_PID" ] && color=r
|
|
|
|
echo -n "\005{+ ."$color"}*\005{-}"
|