@@ -221,6 +221,7 @@ def __init__(
221
221
api_key : str ,
222
222
ssh_user : str ,
223
223
sign_gpg : bool ,
224
+ ssh_key : str | None = None ,
224
225
first_state : Task | None = None ,
225
226
) -> None :
226
227
self .tasks = tasks
@@ -243,6 +244,8 @@ def __init__(
243
244
self .db ["auth_info" ] = api_key
244
245
if not self .db .get ("ssh_user" ):
245
246
self .db ["ssh_user" ] = ssh_user
247
+ if not self .db .get ("ssh_key" ):
248
+ self .db ["ssh_key" ] = ssh_key
246
249
if not self .db .get ("sign_gpg" ):
247
250
self .db ["sign_gpg" ] = sign_gpg
248
251
@@ -255,6 +258,7 @@ def __init__(
255
258
print (f"- Normalized release tag: { release_tag .normalized ()} " )
256
259
print (f"- Git repo: { self .db ['git_repo' ]} " )
257
260
print (f"- SSH username: { self .db ['ssh_user' ]} " )
261
+ print (f"- SSH key: { self .db ['ssh_key' ] or 'Default' } " )
258
262
print (f"- Sign with GPG: { self .db ['sign_gpg' ]} " )
259
263
print ()
260
264
@@ -340,17 +344,23 @@ def check_ssh_connection(db: ReleaseShelf) -> None:
340
344
client = paramiko .SSHClient ()
341
345
client .load_system_host_keys ()
342
346
client .set_missing_host_key_policy (paramiko .WarningPolicy )
343
- client .connect (DOWNLOADS_SERVER , port = 22 , username = db ["ssh_user" ])
347
+ client .connect (
348
+ DOWNLOADS_SERVER , port = 22 , username = db ["ssh_user" ], key_filename = db ["ssh_key" ]
349
+ )
344
350
client .exec_command ("pwd" )
345
- client .connect (DOCS_SERVER , port = 22 , username = db ["ssh_user" ])
351
+ client .connect (
352
+ DOCS_SERVER , port = 22 , username = db ["ssh_user" ], key_filename = db ["ssh_key" ]
353
+ )
346
354
client .exec_command ("pwd" )
347
355
348
356
349
357
def check_sigstore_client (db : ReleaseShelf ) -> None :
350
358
client = paramiko .SSHClient ()
351
359
client .load_system_host_keys ()
352
360
client .set_missing_host_key_policy (paramiko .WarningPolicy )
353
- client .connect (DOWNLOADS_SERVER , port = 22 , username = db ["ssh_user" ])
361
+ client .connect (
362
+ DOWNLOADS_SERVER , port = 22 , username = db ["ssh_user" ], key_filename = db ["ssh_key" ]
363
+ )
354
364
_ , stdout , _ = client .exec_command ("python3 -m sigstore --version" )
355
365
sigstore_version = stdout .read (1000 ).decode ()
356
366
sigstore_vermatch = re .match ("^sigstore ([0-9.]+)" , sigstore_version )
@@ -659,7 +669,7 @@ def sign_source_artifacts(db: ReleaseShelf) -> None:
659
669
660
670
subprocess .check_call (
661
671
[
662
- "python3" ,
672
+ sys . executable ,
663
673
"-m" ,
664
674
"sigstore" ,
665
675
"sign" ,
@@ -730,7 +740,7 @@ def upload_files_to_server(db: ReleaseShelf, server: str) -> None:
730
740
client = paramiko .SSHClient ()
731
741
client .load_system_host_keys ()
732
742
client .set_missing_host_key_policy (paramiko .WarningPolicy )
733
- client .connect (server , port = 22 , username = db ["ssh_user" ])
743
+ client .connect (server , port = 22 , username = db ["ssh_user" ], key_filename = db [ "ssh_key" ] )
734
744
transport = client .get_transport ()
735
745
assert transport is not None , f"SSH transport to { server } is None"
736
746
@@ -775,7 +785,9 @@ def place_files_in_download_folder(db: ReleaseShelf) -> None:
775
785
client = paramiko .SSHClient ()
776
786
client .load_system_host_keys ()
777
787
client .set_missing_host_key_policy (paramiko .WarningPolicy )
778
- client .connect (DOWNLOADS_SERVER , port = 22 , username = db ["ssh_user" ])
788
+ client .connect (
789
+ DOWNLOADS_SERVER , port = 22 , username = db ["ssh_user" ], key_filename = db ["ssh_key" ]
790
+ )
779
791
transport = client .get_transport ()
780
792
assert transport is not None , f"SSH transport to { DOWNLOADS_SERVER } is None"
781
793
@@ -826,7 +838,9 @@ def unpack_docs_in_the_docs_server(db: ReleaseShelf) -> None:
826
838
client = paramiko .SSHClient ()
827
839
client .load_system_host_keys ()
828
840
client .set_missing_host_key_policy (paramiko .WarningPolicy )
829
- client .connect (DOCS_SERVER , port = 22 , username = db ["ssh_user" ])
841
+ client .connect (
842
+ DOCS_SERVER , port = 22 , username = db ["ssh_user" ], key_filename = db ["ssh_key" ]
843
+ )
830
844
transport = client .get_transport ()
831
845
assert transport is not None , f"SSH transport to { DOCS_SERVER } is None"
832
846
@@ -968,7 +982,9 @@ def wait_until_all_files_are_in_folder(db: ReleaseShelf) -> None:
968
982
client = paramiko .SSHClient ()
969
983
client .load_system_host_keys ()
970
984
client .set_missing_host_key_policy (paramiko .WarningPolicy )
971
- client .connect (DOWNLOADS_SERVER , port = 22 , username = db ["ssh_user" ])
985
+ client .connect (
986
+ DOWNLOADS_SERVER , port = 22 , username = db ["ssh_user" ], key_filename = db ["ssh_key" ]
987
+ )
972
988
ftp_client = client .open_sftp ()
973
989
974
990
destination = f"/srv/www.python.org/ftp/python/{ db ['release' ].normalized ()} "
@@ -1006,7 +1022,9 @@ def run_add_to_python_dot_org(db: ReleaseShelf) -> None:
1006
1022
client = paramiko .SSHClient ()
1007
1023
client .load_system_host_keys ()
1008
1024
client .set_missing_host_key_policy (paramiko .WarningPolicy )
1009
- client .connect (DOWNLOADS_SERVER , port = 22 , username = db ["ssh_user" ])
1025
+ client .connect (
1026
+ DOWNLOADS_SERVER , port = 22 , username = db ["ssh_user" ], key_filename = db ["ssh_key" ]
1027
+ )
1010
1028
transport = client .get_transport ()
1011
1029
assert transport is not None , f"SSH transport to { DOWNLOADS_SERVER } is None"
1012
1030
@@ -1344,6 +1362,13 @@ def _api_key(api_key: str) -> str:
1344
1362
help = "Username to be used when authenticating via ssh" ,
1345
1363
type = str ,
1346
1364
)
1365
+ parser .add_argument (
1366
+ "--ssh-key" ,
1367
+ dest = "ssh_key" ,
1368
+ default = None ,
1369
+ help = "Path to the SSH key file to use for authentication" ,
1370
+ type = str ,
1371
+ )
1347
1372
args = parser .parse_args ()
1348
1373
1349
1374
auth_key = args .auth_key or os .getenv ("AUTH_INFO" )
@@ -1432,6 +1457,7 @@ def _api_key(api_key: str) -> str:
1432
1457
api_key = auth_key ,
1433
1458
ssh_user = args .ssh_user ,
1434
1459
sign_gpg = not no_gpg ,
1460
+ ssh_key = args .ssh_key ,
1435
1461
tasks = tasks ,
1436
1462
)
1437
1463
automata .run ()
0 commit comments