Pastebin

Paste #1476: .kde/Autostart/kde-ssh-add.py

< previous paste - next paste>

Pasted by tdn

Download View as text

#!/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


Do not write anything in this field if you're a human.

Go to most recent paste.