Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(cli): ssh setup and key usage #3615

Merged
merged 6 commits into from
Sep 26, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion renku/command/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def search_session_providers_command():

def session_list_command():
"""List all the running interactive sessions."""
return Command().command(session_list)
return Command().command(session_list).with_database(write=False)


def session_start_command():
Expand Down
5 changes: 2 additions & 3 deletions renku/core/session/renkulab.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,8 +299,6 @@ def session_list(self, project_name: str, ssh_garbage_collection: bool = True) -
params=self._get_renku_project_name_parts(),
)
if sessions_res.status_code == 200:
system_config = SystemSSHConfig()
name = self._project_name_from_full_project_name(project_name)
sessions = [
Session(
id=session["name"],
Expand All @@ -310,7 +308,8 @@ def session_list(self, project_name: str, ssh_garbage_collection: bool = True) -
commit=session.get("annotations", {}).get("renku.io/commit-sha"),
branch=session.get("annotations", {}).get("renku.io/branch"),
provider="renkulab",
ssh_enabled=system_config.session_config_path(name, session["name"]).exists(),
ssh_enabled=get_value("renku", "ssh_supported") == "true"
or project_context.project.template_metadata.ssh_supported,
)
for session in sessions_res.json().get("servers", {}).values()
]
Expand Down
5 changes: 5 additions & 0 deletions renku/core/session/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,3 +353,8 @@ def ssh_setup(existing_key: Optional[Path] = None, force: bool = False):
"""
)
f.write(content)

communication.warn(
"This command does not add any public SSH keys into your project. "
olevski marked this conversation as resolved.
Show resolved Hide resolved
"Keys have to be added manually or by using the renku session start command with the --ssh flag."
olevski marked this conversation as resolved.
Show resolved Hide resolved
)
6 changes: 6 additions & 0 deletions renku/core/util/ssh.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,12 @@ def setup_session_config(self, project_name: str, session_name: str) -> str:
ServerAliveCountMax 3
ProxyJump jumphost-{self.renku_host}
IdentityFile {self.keyfile}
IdentityFile ~/.ssh/id_rsa
IdentityFile ~/.ssh/id_ecdsa
IdentityFile ~/.ssh/id_ecdsa_sk
IdentityFile ~/.ssh/id_ed25519
IdentityFile ~/.ssh/id_ed25519_sk
IdentityFile ~/.ssh/id_dsa
User jovyan
StrictHostKeyChecking no
"""
Expand Down
6 changes: 5 additions & 1 deletion renku/ui/cli/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,11 @@ def open(session_name, provider, **kwargs):
)
@click.option("--force", is_flag=True, help="Overwrite existing keys/config.")
def ssh_setup(existing_key, force):
"""Setup keys for SSH connections into sessions."""
"""Generate keys and configuration for SSH connections into sessions.

Note that this will not add any keys to a specific project, adding keys to a project
has to be done manually or through the renku session start command by using the --ssh flag.
"""
from renku.command.session import ssh_setup_command

communicator = ClickCallback()
Expand Down