diff --git a/sshagent/__main__.py b/sshagent/__main__.py index 62099e4..3afef52 100644 --- a/sshagent/__main__.py +++ b/sshagent/__main__.py @@ -6,7 +6,6 @@ import subprocess from . import trezor from . import server -from . import util import logging log = logging.getLogger(__name__) @@ -65,6 +64,15 @@ def setup_logging(verbosity): logging.basicConfig(format=fmt, level=level) +def ssh_command(identity): + command = ['ssh', identity.host] + if identity.user: + command += ['-l', identity.user] + if identity.port: + command += ['-p', identity.port] + return command + + def trezor_agent(): args = create_parser().parse_args() setup_logging(verbosity=args.verbose) @@ -85,13 +93,8 @@ def trezor_agent(): use_shell = False if args.connect: - command = ['ssh', util.to_ascii(identity.host)] - if identity.user: - command += ['-l', util.to_ascii(identity.user)] - if identity.port: - command += ['-p', util.to_ascii(identity.port)] + command = ssh_command(identity) + args.command log.debug('SSH connect: %r', command) - command = command + args.command if args.shell: command, use_shell = os.environ['SHELL'], True diff --git a/sshagent/tests/test_utils.py b/sshagent/tests/test_utils.py index 928f656..9d88eec 100644 --- a/sshagent/tests/test_utils.py +++ b/sshagent/tests/test_utils.py @@ -45,7 +45,3 @@ def test_send_recv(): assert util.recv(s, 2) == b'3*' pytest.raises(EOFError, util.recv, s, 1) - - -def test_ascii(): - assert util.to_ascii(b'123abc') == '123abc' diff --git a/sshagent/util.py b/sshagent/util.py index d169a28..eeac94f 100644 --- a/sshagent/util.py +++ b/sshagent/util.py @@ -64,7 +64,3 @@ def frame(*msgs): res.write(msg) msg = res.getvalue() return pack('L', len(msg)) + msg - - -def to_ascii(s): - return s.decode('ascii')