Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
freedombone
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Context Sensitive Group
freedombone
Commits
b17813f7
Commit
b17813f7
authored
8 years ago
by
Bob Mottram
Browse files
Options
Downloads
Patches
Plain Diff
password store command
parent
8a307d4e
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/freedombone-pass
+137
-0
137 additions, 0 deletions
src/freedombone-pass
with
137 additions
and
0 deletions
src/freedombone-pass
0 → 100755
+
137
−
0
View file @
b17813f7
#!/bin/bash
#
# .---. . .
# | | |
# |--- .--. .-. .-. .-.| .-. .--.--. |.-. .-. .--. .-.
# | | (.-' (.-' ( | ( )| | | | )( )| | (.-'
# ' ' --' --' -' - -' ' ' -' -' -' ' - --'
#
# Freedom in the Cloud
#
# Simple multi-user password store using symmetric encryption
# and the backup gpg key
#
# License
# =======
#
# Copyright (C) 2016 Bob Mottram <bob@freedombone.net>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero 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 Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
PROJECT_NAME
=
'freedombone'
export
TEXTDOMAIN
=
${
PROJECT_NAME
}
-pass
export
TEXTDOMAINDIR
=
"/usr/share/locale"
MY_BACKUP_KEY_ID
=
CURR_USERNAME
=
CURR_APP
=
CURR_PASSWORD
=
function
get_backup_key_id
{
MY_BACKUP_KEY_ID
=
$(
gpg
--list-keys
"(backup key)"
|
\
grep
'pub '
|
awk
-F
' '
'{print $2}'
|
\
awk
-F
'/'
'{print $2}'
)
if
[
${#
MY_BACKUP_KEY_ID
}
-lt
4
]
;
then
echo
$"gpg backup key was not found"
return
58213
fi
}
function
show_help
{
echo
''
echo
$"
${
PROJECT_NAME
}
-pass"
echo
''
echo
$'Password store using gpg'
echo
''
echo
$' --help Show help'
echo
$' -u --user Username'
echo
$' -a --app [name] Name of the application'
echo
$' -p --pass [password] The password to store'
echo
''
echo
$'To encrypt a password:'
echo
''
echo
$"
${
PROJECT_NAME
}
-pass -u [username] -a [app] -p [password]"
echo
''
echo
$'To retrieve a password:'
echo
$''
echo
$"
${
PROJECT_NAME
}
-pass -u [username] -a [app]"
echo
''
exit
0
}
while
[[
$#
>
1
]]
do
key
=
"
$1
"
case
$key
in
--help
)
show_help
;;
-u
|
--user
|
--username
)
shift
CURR_USERNAME
=
"
${
1
}
"
;;
-a
|
--app
|
--application
)
shift
CURR_APP
=
"
${
1
}
"
;;
-p
|
--pass
|
--password
|
--passphrase
)
shift
CURR_PASSWORD
=
"
${
1
}
"
;;
*
)
# unknown option
;;
esac
shift
done
MASTER_PASSWORD
=
$(
gpg
-q
--armor
--export-secret-key
'backup key'
)
if
[
!
$CURR_USERNAME
]
;
then
echo
$'No username given'
exit
1
fi
if
[
!
-d
/home/
$CURR_USERNAME
]
;
then
echo
$"User
$CURR_USERNAME
does not exist"
exit
2
fi
if
[
!
$CURR_APP
]
;
then
echo
$'No app name given'
exit
3
fi
if
[
!
$CURR_PASSWORD
]
;
then
# retrieve password
if
[
!
-f
~/.passwords/
$CURR_USER
/
$CURR_APP
]
;
then
echo
""
exit
4
else
gpg
-dq
--passphrase
"
$MASTER_PASSWORD
"
~/.passwords/
$CURR_USER
/
$CURR_APP
fi
else
# store password
if
[
!
-d
~/.passwords/
$CURR_USER
]
;
then
mkdir
-p
~/.passwords/
$CURR_USER
fi
echo
“
$CURR_PASSWORD
” | gpg
-ca
--cipher-algo
AES256
--passphrase
"
$MASTER_PASSWORD
"
>
~/.passwords/
$CURR_USER
/
$CURR_APP
if
[
!
-f
~/.passwords/
$CURR_USER
/
$CURR_APP
]
;
then
exit
5
fi
fi
exit
0
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment