Skip to content

Commit

Permalink
Viewer: Various SSH username handling improvements
Browse files Browse the repository at this point in the history
(refer to change log)
  • Loading branch information
dcommander committed Sep 13, 2023
1 parent dc35558 commit 2d7a420
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
10 changes: 10 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@
1. The TurboVNC Viewer now asks for confirmation before overwriting an existing
screenshot file.

2. Improved the TurboVNC Viewer's handling of SSH usernames in the following
ways:

- To better emulate the behavior of OpenSSH, the TurboVNC Viewer's
built-in SSH client now allows an SSH username specified on the command line or
in a connection info file to override an SSH username specified in the OpenSSH
config file.
- The `LocalUsernameLC` parameter now affects the SSH username if the SSH
username is unspecified.


3.0.3
=====
Expand Down
3 changes: 2 additions & 1 deletion java/com/turbovnc/rfb/Params.java
Original file line number Diff line number Diff line change
Expand Up @@ -767,7 +767,8 @@ public static void reset() {

public static BoolParameter localUsernameLC =
new BoolParameter("LocalUsernameLC",
"When the SendLocalUsername parameter is set, setting this parameter will " +
"When the SendLocalUsername parameter is set, or when using SSH " +
"tunneling without a specified SSH username, setting this parameter will " +
"cause the local username to be sent in lowercase, which may be useful " +
"when using the viewer on Windows machines (Windows allows mixed-case " +
"usernames, whereas Un*x and Mac platforms generally don't.)", false);
Expand Down
10 changes: 7 additions & 3 deletions java/com/turbovnc/vncviewer/Tunnel.java
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,6 @@ protected static void createTunnelJSch(String host, Options opts)
// username and passphrase will be given via UserInfo interface.
int port = Params.sshPort.getValue();
String user = opts.sshUser;
if (user == null)
user = (String)System.getProperties().get("user.name");

File sshConfigFile = new File(Params.sshConfig.getValue());
if (sshConfigFile.exists() && sshConfigFile.canRead()) {
Expand All @@ -182,7 +180,7 @@ protected static void createTunnelJSch(String host, Options opts)
// getSession() if the configuration has already been set using an
// OpenSSH configuration file.
String repoUser = repo.getConfig(host).getUser();
if (repoUser != null)
if (repoUser != null && user == null)
user = repoUser;
String[] identityFiles = repo.getConfig(host).getValues("IdentityFile");
if (identityFiles != null) {
Expand All @@ -201,6 +199,12 @@ protected static void createTunnelJSch(String host, Options opts)
}
}

if (user == null) {
user = (String)System.getProperties().get("user.name");
if (Params.localUsernameLC.getValue())
user = user.toLowerCase();
}

if (useDefaultPrivateKeyFiles) {
privateKeys.add(new File(homeDir + "/.ssh/id_rsa"));
privateKeys.add(new File(homeDir + "/.ssh/id_dsa"));
Expand Down

0 comments on commit 2d7a420

Please sign in to comment.