lastpass-ssh 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/bin/lastpass-ssh +95 -0
- metadata +45 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: dbba1f6971c4b5a01812a7dc5beb53c50ca9a51a
|
4
|
+
data.tar.gz: f95ba51fd48e9089037acc6caa9186453ff80eb7
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d228120fd725cc636f6b2a9badfa1f6c6c022401b9ade2ad09f4ed08cb9b33646a4c59f231a35570350b0ef087afb0fbc5f507333e205f0730319fad56952f96
|
7
|
+
data.tar.gz: 2d3a8d13e12f480559ed9d6a2f2ca0aa971c63adc0e68063ff5a7fefea57e6f24aa7a60309a7d0ee94a023093967c2a6ffe8ef6c1f2c2c51649d0899dbdc24fe
|
data/bin/lastpass-ssh
ADDED
@@ -0,0 +1,95 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# Copyright 2015 Wojciech A. Koszek <wojciech@koszek.com>
|
3
|
+
#
|
4
|
+
# Inspired by:
|
5
|
+
#
|
6
|
+
# https://gist.github.com/davidblewett/53047c4c7757b663c11b
|
7
|
+
# http://pentestmonkey.net/blog/ssh-with-no-tty
|
8
|
+
#
|
9
|
+
# 1st didn't work for me out of the box on MacOSX. I made this script instead to
|
10
|
+
# handle both adding all keys and passing the passphrase to an ssh-add.
|
11
|
+
require 'optparse'
|
12
|
+
|
13
|
+
fn_abs = File.absolute_path($0)
|
14
|
+
|
15
|
+
if not `lpass --version` =~ /LastPass/ then
|
16
|
+
print "You don't have LastPass CLI installed. Do:\n"
|
17
|
+
print "brew install lpass # on Mac\n"
|
18
|
+
print "apt-get install lpass # on Ubuntu\n"
|
19
|
+
exit 64
|
20
|
+
end
|
21
|
+
|
22
|
+
g_debug = false
|
23
|
+
g_keys_path = ENV["HOME"] + "/.ssh"
|
24
|
+
g_keys_to_add = nil
|
25
|
+
ARGV.options do |opts|
|
26
|
+
opts.on("-k", "--key=[x,y,z]", Array) {
|
27
|
+
|a| g_keys_to_add = a
|
28
|
+
}
|
29
|
+
opts.on("-P", "--keys-path=val", String) {
|
30
|
+
|s| g_keys_path = s
|
31
|
+
}
|
32
|
+
opts.on("-d", "--debug") {
|
33
|
+
g_debug = true
|
34
|
+
}
|
35
|
+
opts.on("-h", "--help") {
|
36
|
+
print "lastpass-ssh:\n"
|
37
|
+
print " --keys-path <path> use <path> instead of ~/.ssh"
|
38
|
+
print " --help print this help\n"
|
39
|
+
exit 0
|
40
|
+
}
|
41
|
+
opts.parse!
|
42
|
+
end
|
43
|
+
|
44
|
+
if g_debug then
|
45
|
+
print "DBG: #{g_keys_to_add}\n"
|
46
|
+
print "DBG: #{g_keys_path}\n"
|
47
|
+
end
|
48
|
+
|
49
|
+
if not g_keys_path then
|
50
|
+
print "you must pass path to --keys-path\n"
|
51
|
+
exit 64
|
52
|
+
end
|
53
|
+
|
54
|
+
if ENV["KEY_ID"] then
|
55
|
+
r = `lpass show --field Passphrase #{ENV['KEY_ID']}`
|
56
|
+
print r
|
57
|
+
else
|
58
|
+
# Lines will be e.g.: 'Secure Notes\SSH/bitbucket [id: 5505843262]'
|
59
|
+
raw_lines = `lpass ls "Secure Notes\\SSH"`
|
60
|
+
lines = raw_lines.split("\n").select { |l| l if l =~ /^Secure/ }
|
61
|
+
|
62
|
+
label_printed = false
|
63
|
+
# Use key's name, make path out of it, attempt to add it by its ID
|
64
|
+
lines.each.map{ |l| l.scan(/\w+/)}.each do |sec, notes, ssh, key_name, id_str, key_id|
|
65
|
+
if g_keys_to_add != nil then
|
66
|
+
if not label_printed then
|
67
|
+
print "# Requested to add key #{g_keys_to_add}\n"
|
68
|
+
label_printed = true
|
69
|
+
end
|
70
|
+
if not g_keys_to_add.include?(key_name) then
|
71
|
+
print "Skipping #{key_name}\n"
|
72
|
+
next
|
73
|
+
end
|
74
|
+
end
|
75
|
+
fork do
|
76
|
+
ENV["KEY_ID"] = key_id
|
77
|
+
ENV["SSH_ASKPASS"] = fn_abs
|
78
|
+
ENV["DISPLAY"] = "foo"
|
79
|
+
print "LastPass key ID #{key_id} name #{key_name} "
|
80
|
+
if key_name =~ /^lpass_/ then
|
81
|
+
key_body = `lpass show --notes #{key_id}`
|
82
|
+
if key_body.strip().empty? then
|
83
|
+
print "LastPass 'Notes' section of key " +
|
84
|
+
"'#{key_name}' is empty (no key defined)!\n"
|
85
|
+
exit 1
|
86
|
+
end
|
87
|
+
exec "lpass show --notes #{key_id} | ssh-add -"
|
88
|
+
else
|
89
|
+
exec "ssh-add #{g_keys_path}/#{key_name} < /dev/null"
|
90
|
+
end
|
91
|
+
|
92
|
+
end
|
93
|
+
Process.wait
|
94
|
+
end
|
95
|
+
end
|
metadata
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: lastpass-ssh
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Wojciech A. Koszek
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-09-17 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: lastpass-cli helps with storing SSH passphrases in LastPass
|
14
|
+
email: wojciech@koszek.com
|
15
|
+
executables:
|
16
|
+
- lastpass-ssh
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- bin/lastpass-ssh
|
21
|
+
homepage: http://github.com/wkoszek/lastpass-ssh
|
22
|
+
licenses:
|
23
|
+
- BSD
|
24
|
+
metadata: {}
|
25
|
+
post_install_message:
|
26
|
+
rdoc_options: []
|
27
|
+
require_paths:
|
28
|
+
- lib
|
29
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
35
|
+
requirements:
|
36
|
+
- - '>='
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '0'
|
39
|
+
requirements: []
|
40
|
+
rubyforge_project:
|
41
|
+
rubygems_version: 2.0.14
|
42
|
+
signing_key:
|
43
|
+
specification_version: 4
|
44
|
+
summary: Integrate SSH keys with LastPass
|
45
|
+
test_files: []
|