Skip to content

Commit 3c974d6

Browse files
author
Andrea Negri
committed
Merge branch 'feature/ssh-agent' into dev
2 parents 8d4b7d8 + 845862a commit 3c974d6

11 files changed

Lines changed: 197 additions & 77 deletions

File tree

.github/workflows/main.yml

Lines changed: 75 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
- ubuntu-20.04
3232
turbovnc-version:
3333
- "3.1"
34-
- "2.2.7"
34+
# - "2.2.7"
3535
include:
3636
- os: macos-13
3737
turbovnc-version: "none"
@@ -42,7 +42,7 @@ jobs:
4242
runs-on: ${{ matrix.os }}
4343
permissions:
4444
attestations: write
45-
contents: read
45+
contents: write
4646
id-token: write
4747

4848
# Steps represent a sequence of tasks that will be executed as part of the job
@@ -76,48 +76,72 @@ jobs:
7676
}
7777
echo "EXT=.exe" >> "${env:GITHUB_ENV}"
7878
79-
- name: Define artifact basename
79+
# ======================================================================
80+
# CI VARIABLES
81+
# ======================================================================
82+
- name: Define platform
8083
uses: carlkidcrypto/os-specific-runner@v2.0.0
8184
env:
8285
RUNNER_ARCH: ${{ runner.arch }}
8386
with:
8487
macos: |
8588
runner_arch=$(echo "${RUNNER_ARCH}" | tr '[:upper:]' '[:lower:]')
86-
echo "ARTIFACT_BASENAME=RCM-client_${{ matrix.os }}_${runner_arch}" >> "${GITHUB_ENV}"
87-
linux: echo "ARTIFACT_BASENAME=RCM-client_${{ matrix.os }}_${RUNNER_ARCH,,}_turbovnc_${{ matrix.turbovnc-version }}" >> "${GITHUB_ENV}"
89+
echo "ARTIFACT_PLATFORM=${{ matrix.os }}_${runner_arch}" >> "${GITHUB_ENV}"
90+
linux: |
91+
echo "ARTIFACT_PLATFORM=${{ matrix.os }}_${RUNNER_ARCH,,}" >> "${GITHUB_ENV}"
8892
windows: |
8993
$runner_arch=${env:RUNNER_ARCH}.toLower()
90-
echo "ARTIFACT_BASENAME=RCM-client_${{ matrix.os }}_${runner_arch}_turbovnc_${{ matrix.turbovnc-version }}" >> "${env:GITHUB_ENV}"
94+
echo "ARTIFACT_PLATFORM=${{ matrix.os }}_${runner_arch}" >> "${env:GITHUB_ENV}"
95+
96+
- name: Define artifact basename
97+
shell: bash
98+
run: echo "ARTIFACT_BASENAME=RCM-client--${{ env.ARTIFACT_PLATFORM }}" >> "${GITHUB_ENV}"
99+
100+
- name: Define artifact version for tag
101+
if: ${{ github.event_name == 'push' && contains(github.ref, 'refs/tags/') }}
102+
shell: bash
103+
run: echo "ARTIFACT_VERSION=${{ github.ref_name }}" >> "${GITHUB_ENV}"
104+
105+
- name: Define artifact version for normal commit
106+
if: ${{ github.event_name != 'push' && !contains(github.ref, 'refs/tags/') }}
107+
shell: bash
108+
run: echo "ARTIFACT_VERSION=${{ github.sha }}" >> "${GITHUB_ENV}"
91109

110+
# ======================================================================
92111
# CACHE
112+
# ======================================================================
93113
- name: (GHO) Cache pyenv
94114
uses: actions/cache@v4.0.0
95115
id: cache-pyenv
96116
with:
97117
path: .pyenv
98-
key: pyenv-${{ env.PYENV_VERSION }}-python-${{ env.PYTHON_VERSION }}-${{ matrix.os }}
118+
key: pyenv-${{ env.PYENV_VERSION }}-python-${{ env.PYTHON_VERSION }}-${{ matrix.os }}-${{ hashFiles('scripts/ci/02-install-python.*') }}
99119

100120
- name: (GHO) Cache venv
101121
uses: actions/cache@v4.0.0
102122
id: cache-venv
103123
with:
104124
path: .venv
105-
key: venv-python-${{ env.PYTHON_VERSION }}-${{ hashFiles( format('{0}/rcm/client/requirements.txt', env.RCM_CHECKOUT ) ) }}-paramiko-${{ env.PARAMIKO_PULL }}-${{env.PARAMIKO_COMMIT}}-${{ matrix.os }}
125+
key: venv-python-${{ env.PYTHON_VERSION }}-paramiko-${{ env.PARAMIKO_PULL }}-${{env.PARAMIKO_COMMIT}}-${{ matrix.os }}-${{ hashFiles('scripts/ci/03-install-venv.*', '**/requirements.txt') }}
106126

107127
- name: (GHO) Cache turbovnc
108128
uses: actions/cache@v4.0.0
109129
id: cache-turbovnc
110130
with:
111131
path: ${{ env.RCM_CHECKOUT }}/${{ env.TURBOVNC_EXTERNAL }}
112-
key: turbovnc-${{ matrix.turbovnc-version }}-${{ matrix.os }}
132+
key: turbovnc-${{ matrix.turbovnc-version }}-${{ matrix.os }}-${{ hashFiles('scripts/ci/04*') }}
113133

114134
- name: (GHO) Cache step
115135
uses: actions/cache@v4.0.0
116136
id: cache-step
117137
with:
118-
path: ${{ env.RCM_CHECKOUT }}/${{ env.SMALLSTEP_EXTERNAL }}
138+
path: ${{ env.RCM_CHECKOUT }}/${{ env.SMALLSTEP_EXTERNAL }}-${{ hashFiles('scripts/ci/05*') }}
119139
key: step-${{ matrix.os }}
120140

141+
# ======================================================================
142+
# CI STEPS
143+
# ======================================================================
144+
121145
# PYTHON
122146
- name: Setup pyenv environment
123147
uses: carlkidcrypto/os-specific-runner@v2.0.0
@@ -171,21 +195,31 @@ jobs:
171195
linux: . "${RCM_CHECKOUT}/scripts/ci/05-extract-step-linux.sh"
172196
windows: . "${env:RCM_CHECKOUT}\scripts\ci\05-extract-step.ps1"
173197

198+
# EXTERNAL PLINK
199+
- name: External plink (windows)
200+
uses: carlkidcrypto/os-specific-runner@v2.0.0
201+
with:
202+
windows: . "${env:RCM_CHECKOUT}\scripts\ci\06-download-plink.ps1"
203+
204+
# ======================================================================
174205
# PYINSTALLER
206+
# ======================================================================
175207
- name: Build pyinstaller
176208
uses: carlkidcrypto/os-specific-runner@v2.0.0
177209
with:
178210
macos: |
179211
source .venv/bin/activate
180-
pyinstaller "${RCM_CHECKOUT}/rcm/client/rcm_client_qt.spec"
212+
pyinstaller "${RCM_CHECKOUT}/rcm/client/rcm_client_qt.spec" -- ${{ env.ARTIFACT_VERSION }} ${{ env.ARTIFACT_PLATFORM }}
181213
linux: |
182214
source .venv/bin/activate
183-
pyinstaller "${RCM_CHECKOUT}/rcm/client/rcm_client_qt.spec"
215+
pyinstaller "${RCM_CHECKOUT}/rcm/client/rcm_client_qt.spec" -- ${{ env.ARTIFACT_VERSION }} ${{ env.ARTIFACT_PLATFORM }}
184216
windows: |
185217
.venv\Scripts\Activate.ps1
186-
pyinstaller "${env:RCM_CHECKOUT}\rcm\client\rcm_client_qt.spec"
218+
pyinstaller "${env:RCM_CHECKOUT}\rcm\client\rcm_client_qt.spec" -- ${{ env.ARTIFACT_VERSION }} ${{ env.ARTIFACT_PLATFORM }}
187219
188-
# ARTIFACT
220+
# ======================================================================
221+
# ARTIFACTS AND RELESES
222+
# ======================================================================
189223
- name: (GHO) Move preartifacts
190224
shell: bash
191225
run: |
@@ -194,42 +228,55 @@ jobs:
194228
find dist -type f -name "RCM${{ env.EXT }}" -exec cp '{}' . \;
195229
find dist -type f -name "RCM.zip" -exec cp '{}' . \;
196230
197-
- name: (Attestation) Attest RCM executable
198-
uses: actions/attest-build-provenance@1c608d11d69870c2092266b3f9a6f3abbf17002c # v1.4.3
199-
with:
200-
subject-path: RCM${{ env.EXT }}
201-
subject-name: ${{ env.ARTIFACT_BASENAME }}
202-
203-
- name: (Attestation) Attest RCM zip
204-
uses: actions/attest-build-provenance@1c608d11d69870c2092266b3f9a6f3abbf17002c # v1.4.3
231+
# TAG RELEASE
232+
- name: (GHO)(TAG) Upload exe to release
233+
if: ${{ github.event_name == 'push' && contains(github.ref, 'refs/tags/') }}
234+
uses: svenstaro/upload-release-action@v2
205235
with:
206-
subject-path: RCM.zip
207-
subject-name: ${{ env.ARTIFACT_BASENAME }}-dir
236+
file: RCM${{ env.EXT }}
237+
asset_name: ${{ env.ARTIFACT_BASENAME }}--${{ env.ARTIFACT_VERSION }}${{ env.EXT }}
238+
prerelease: true
239+
overwrite: true
240+
tag: ${{ github.ref }}
208241

209242
- name: (GHO)(TAG) Upload exe to release
210243
if: ${{ github.event_name == 'push' && contains(github.ref, 'refs/tags/') }}
211244
uses: svenstaro/upload-release-action@v2
212245
with:
213-
file: RCM${{ env.EXT }}
214-
asset_name: ${{ env.ARTIFACT_BASENAME }}${{ env.EXT }}
246+
file: RCM.zip
247+
asset_name: ${{ env.ARTIFACT_BASENAME }}--${{ env.ARTIFACT_VERSION }}.zip
215248
prerelease: true
216249
overwrite: true
217250
tag: ${{ github.ref }}
218251

252+
# CI ARTIFACT
219253
- name: (GHO) Upload artifact exe
220254
if: ${{ github.event_name != 'push' && !contains(github.ref, 'refs/tags/') }}
221255
uses: actions/upload-artifact@v4.3.1
222256
with:
223-
name: ${{ env.ARTIFACT_BASENAME }}
257+
name: ${{ env.ARTIFACT_BASENAME }}--${{ env.ARTIFACT_VERSION }}
224258
path: RCM${{ env.EXT }}
225259

226260
- name: (GHO) Upload artifact dir
227261
if: ${{ github.event_name != 'push' && !contains(github.ref, 'refs/tags/') }}
228262
uses: actions/upload-artifact@v4.3.1
229263
with:
230-
name: ${{ env.ARTIFACT_BASENAME }}-dir
264+
name: ${{ env.ARTIFACT_BASENAME }}--${{ env.ARTIFACT_VERSION }}-dir
231265
path: RCM.zip
232266

267+
# ATTESTATION
268+
- name: (Attestation) Attest RCM executable
269+
uses: actions/attest-build-provenance@1c608d11d69870c2092266b3f9a6f3abbf17002c # v1.4.3
270+
with:
271+
subject-path: RCM${{ env.EXT }}
272+
subject-name: ${{ env.ARTIFACT_BASENAME }}--${{ env.ARTIFACT_VERSION }}
273+
274+
- name: (Attestation) Attest RCM zip
275+
uses: actions/attest-build-provenance@1c608d11d69870c2092266b3f9a6f3abbf17002c # v1.4.3
276+
with:
277+
subject-path: RCM.zip
278+
subject-name: ${{ env.ARTIFACT_BASENAME }}--${{ env.ARTIFACT_VERSION }}-dir
279+
233280
- name: (Attestation) Verify RCM executable and zip
234281
shell: bash
235282
env:

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
* :herb:`[dep]`: Update *paramiko* to `3.4` (patch required to work with *step*).
1818
* :herb:`[dep]`: Update *TurboVNC* to `3.x` (Windows executable is changed, patch to *Java* required to work with old RCM servers).
1919
* :herb:`[dep]`: Add *step* executables in the bundle.
20+
* :herb:`[dep]`: Add *plink* executables in the bundle (Windows only).
2021
* :beetle:`[bug]`: Fix `subprocess` call on windows (pop up *cmd* terminal).
22+
* :beetle:`[bug]`: Patch `paramiko` connection, when `ssh-agent` is disabled.
23+
* :beetle:`[bug]`: Force `external` tunnelling with OpenSSH, when `ssh-agent` is disabled.
2124
* :window:`[gui]`: Add **RCM** logo in the GUI.
2225
* :package:`[release]`: Add GitHub *attestations*.

rcm/client/external/.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
turbovnc
2-
step
1+
*

rcm/client/logic/manager.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#
33
# Copyright (c) 2014-2019 CINECA.
44
#
5-
# This file is part of RCM (Remote Connection Manager)
5+
# This file is part of RCM (Remote Connection Manager)
66
# (see http://www.hpc.cineca.it/software/rcm).
77
#
88
# This program is free software: you can redistribute it and/or modify
@@ -72,6 +72,9 @@ def __init__(self):
7272
'preload_command',
7373
fallback=defaults['preload_command']))
7474

75+
# Check if ssh agent is active
76+
self.allow_agent = False if paramiko.agent.get_agent_connection() is None else True
77+
7578
def login_setup(self, host, user, password=None, preload=''):
7679
self.proxynode = host
7780
self.preload = preload
@@ -114,7 +117,8 @@ def prex(self, cmd):
114117
ssh = paramiko.SSHClient()
115118
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
116119
try:
117-
ssh.connect(host, username=self.user, password=self.password, timeout=10)
120+
ssh.connect(host, username=self.user, password=self.password, timeout=10,
121+
allow_agent=self.allow_agent)
118122
self.auth_method = ssh.get_transport().auth_handler.auth_method
119123
stdin, stdout, stderr = ssh.exec_command(fullcommand)
120124
out = ''.join(stdout)
@@ -237,7 +241,13 @@ def submit(self, session=None, otp='', gui_cmd=None, configFile=None):
237241
tunnelling_method = json.loads(parser.get('Settings', 'ssh_client'))
238242
except Exception:
239243
tunnelling_method = "internal"
240-
logic_logger.info("Using " + str(tunnelling_method) + " ssh tunnelling")
244+
245+
extra_info = ""
246+
if not self.allow_agent and not self.password:
247+
tunnelling_method = "external"
248+
extra_info = " (forced because ssh-agent is not active)"
249+
250+
logic_logger.info("Using " + str(tunnelling_method) + " ssh tunnelling" + extra_info)
241251

242252
plugin_exe = plugin.TurboVNCExecutable()
243253
plugin_exe.build(session=session, local_portnumber=local_port_number)
@@ -252,7 +262,8 @@ def submit(self, session=None, otp='', gui_cmd=None, configFile=None):
252262
local_port_number,
253263
compute_node,
254264
port_number,
255-
tunnelling_method)
265+
tunnelling_method,
266+
self.allow_agent)
256267

257268
self.session_threads.append(st)
258269
st.start()

0 commit comments

Comments
 (0)