Skip to content

Commit

Permalink
Don't strip username from jumphost, add it if it's missing ; fix bu…
Browse files Browse the repository at this point in the history
…g when connecting with two different usernames for server and jumphost ; fix command line parsing bug when including username in jumphost. (#614)
  • Loading branch information
ddebin authored Feb 1, 2024
1 parent 8f4a121 commit da05312
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/terminal/SshSetupHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ string SshSetupHandler::SetupSsh(const string& user, const string& host,
if (!jumphost.empty()) {
ssh_args = {
"-J",
SSH_USER_PREFIX + jumphost,
jumphost,
};
}

Expand Down
14 changes: 8 additions & 6 deletions src/terminal/TerminalClientMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,11 +259,7 @@ int main(int argc, char** argv) {
string proxyjump = string(sshConfigOptions.ProxyJump);
size_t colonIndex = proxyjump.find(":");
if (colonIndex != string::npos) {
string userhostpair = proxyjump.substr(0, colonIndex);
size_t atIndex = userhostpair.find("@");
if (atIndex != string::npos) {
jumphost = userhostpair.substr(atIndex + 1);
}
jumphost = proxyjump.substr(0, colonIndex);
} else {
jumphost = proxyjump;
}
Expand All @@ -275,7 +271,13 @@ int main(int argc, char** argv) {
if (!jumphost.empty()) {
is_jumphost = true;
LOG(INFO) << "Setting port to jumphost port";
socketEndpoint.set_name(jumphost);
size_t atIndex = jumphost.find("@");
if (atIndex != string::npos) {
socketEndpoint.set_name(jumphost.substr(atIndex + 1));
} else {
socketEndpoint.set_name(jumphost);
jumphost = username + "@" + jumphost;
}
socketEndpoint.set_port(result["jport"].as<int>());
} else {
socketEndpoint.set_name(destinationHost);
Expand Down

0 comments on commit da05312

Please sign in to comment.