diff --git a/src/bastion/azext_bastion/custom.py b/src/bastion/azext_bastion/custom.py index 6cd5e581433..48ca6076fa4 100644 --- a/src/bastion/azext_bastion/custom.py +++ b/src/bastion/azext_bastion/custom.py @@ -322,7 +322,21 @@ def rdp_bastion_host(cmd, target_resource_id, target_ip_address, resource_group_ t = threading.Thread(target=_start_tunnel, args=(tunnel_server,)) t.daemon = True t.start() - command = [_get_rdp_path(), f"/v:localhost:{tunnel_server.local_port}"] + + rdp_file_content = ( + f"full address:s:localhost:{tunnel_server.local_port}\n" + f"alternate full address:s:localhost:{tunnel_server.local_port}\n" + "use multimon:i:1\n" + ) + + rdpfilepath = os.path.join(tempfile.gettempdir(), f'conn_{uuid.uuid4().hex}.rdp') + with open(rdpfilepath, 'w') as rdp_file: + rdp_file.write(rdp_file_content) + + command = [_get_rdp_path()] + if configure: + command.append("/edit") + command.append(rdpfilepath) launch_and_wait(command) tunnel_server.cleanup() else: