14 lines
366 B
Python
14 lines
366 B
Python
#!/usr/bin/env python3
|
|
"""Interactive SSH or a command with literal arguments; shell syntax must be explicit."""
|
|
import os
|
|
import shlex
|
|
import sys
|
|
|
|
|
|
def command(target, arguments):
|
|
return ['ssh', '-o', 'BatchMode=yes', target, *([shlex.join(arguments)] if arguments else [])]
|
|
|
|
|
|
if __name__ == '__main__':
|
|
os.execvp('ssh', command(sys.argv[1], sys.argv[2:]))
|