@@ -94,17 +94,19 @@ class CommandRunner(object):
94
94
sys .exit (sftp_proc .returncode )
95
95
96
96
class RemoteCommandRunner (CommandRunner ):
97
- def __init__ (self , host , identity_path , ssh_options ):
97
+ def __init__ (self , host , identity_path , ssh_options , config_file ):
98
98
if ':' in host :
99
99
(self .remote_host , self .port ) = host .rsplit (':' , 1 )
100
100
else :
101
101
self .remote_host = host
102
102
self .port = None
103
103
self .identity_path = identity_path
104
104
self .ssh_options = ssh_options
105
+ self .config_file = config_file
105
106
106
107
def common_options (self , port_flag ):
107
108
port_option = [port_flag , self .port ] if self .port else []
109
+ config_option = ['-F' , self .config_file ] if self .config_file else []
108
110
identity_option = (
109
111
['-i' , self .identity_path ] if self .identity_path else [])
110
112
# Interleave '-o' with each custom option.
@@ -113,7 +115,7 @@ class RemoteCommandRunner(CommandRunner):
113
115
# https://spapas.github.io/2016/04/27/python-nested-list-comprehensions/
114
116
extra_options = [arg for option in self .ssh_options
115
117
for arg in ["-o" , option ]]
116
- return port_option + identity_option + extra_options
118
+ return port_option + identity_option + config_option + extra_options
117
119
118
120
def remote_invocation (self , command ):
119
121
return (['/usr/bin/ssh' , '-n' ] +
@@ -172,6 +174,8 @@ def main():
172
174
173
175
parser .add_argument ('-i' , '--identity' , dest = 'identity' , metavar = 'FILE' ,
174
176
help = 'an SSH identity file (private key) to use' )
177
+ parser .add_argument ('-F' , '--config-file' , dest = 'config_file' , metavar = 'FILE' ,
178
+ help = 'an SSH configuration file' )
175
179
parser .add_argument ('-o' , '--ssh-option' , action = 'append' , default = [],
176
180
dest = 'ssh_options' , metavar = 'OPTION' ,
177
181
help = 'extra SSH config options (man ssh_config)' )
@@ -192,7 +196,10 @@ def main():
192
196
args .command .insert (0 , args .host )
193
197
del args .host
194
198
else :
195
- runner = RemoteCommandRunner (args .host , args .identity , args .ssh_options )
199
+ runner = RemoteCommandRunner (args .host ,
200
+ args .identity ,
201
+ args .ssh_options ,
202
+ args .config_file )
196
203
runner .dry_run = args .dry_run
197
204
runner .verbose = args .verbose or args .dry_run
198
205
0 commit comments