File tree Expand file tree Collapse file tree 2 files changed +6
-3
lines changed
Expand file tree Collapse file tree 2 files changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -1070,7 +1070,10 @@ def __init__(
10701070 self .python_env = kwargs .get ("ssh_python_env" )
10711071 else :
10721072 if user :
1073- thin_dir = DEFAULT_THIN_DIR .replace ("%%USER%%" , user )
1073+ thin_dir = DEFAULT_THIN_DIR .replace (
1074+ "%%USER%%" ,
1075+ re .sub (r"[^a-zA-Z0-9\._\-@]" , "_" , user ),
1076+ )
10741077 else :
10751078 thin_dir = DEFAULT_THIN_DIR .replace ("%%USER%%" , "root" )
10761079 self .thin_dir = thin_dir .replace (
Original file line number Diff line number Diff line change @@ -156,7 +156,7 @@ def _key_opts(self):
156156 if self .priv and self .priv != "agent-forwarding" :
157157 options .append (f"IdentityFile={ self .priv } " )
158158 if self .user :
159- options .append (f"User={ self .user } " )
159+ options .append (f"User={ shlex . quote ( self .user ) } " )
160160 if self .identities_only :
161161 options .append ("IdentitiesOnly=yes" )
162162
@@ -202,7 +202,7 @@ def _passwd_opts(self):
202202 if self .port :
203203 options .append (f"Port={ self .port } " )
204204 if self .user :
205- options .append (f"User={ self .user } " )
205+ options .append (f"User={ shlex . quote ( self .user ) } " )
206206 if self .identities_only :
207207 options .append ("IdentitiesOnly=yes" )
208208
You can’t perform that action at this time.
0 commit comments