Pastebin
Paste #1476: .kde/Autostart/kde-ssh-add.py
< previous paste - next paste>
Pasted by tdn
#!/usr/bin/env python
import subprocess
import pexpect
def read_key(title, match):
pipe = subprocess.Popen(
'kdialog --password "%s\n\n%s" --title "%s"' % (title, match, "KDE ssh-agent interface"),
shell=True,
stdout=subprocess.PIPE
)
line = pipe.stdout.readline()
del pipe
return line
child = pexpect.spawn('ssh-add')
child.expect('Enter passphrase for (.*):')
keyname = child.match.groups()[0]
child.sendline(read_key("Please input password", keyname))
while child.expect(["Bad passphrase, try again for .*", "Identity added: .*"]) == 0:
child.sendline(read_key("Bad passphrase. Please try again.", keyname))
New Paste
Go to most recent paste.