aboutsummaryrefslogtreecommitdiff
path: root/ssf
diff options
context:
space:
mode:
authorGuillermo Ramos2023-04-13 10:16:11 +0200
committerGuillermo Ramos2023-04-13 10:16:11 +0200
commit5b13777e6d03665d857342c47489e63a67e01f48 (patch)
treed0d61cd40a52636fce5e3cdb1c25f39149761b74 /ssf
parent67f87965bb5cc77d1025d9db60ac86fac2f9b169 (diff)
downloadcli-5b13777e6d03665d857342c47489e63a67e01f48.tar.gz
ssf: configure remote user
Diffstat (limited to 'ssf')
-rwxr-xr-xssf6
1 files changed, 4 insertions, 2 deletions
diff --git a/ssf b/ssf
index f87cd09..2366b29 100755
--- a/ssf
+++ b/ssf
@@ -15,6 +15,8 @@ use warnings;
my @hosts;
my %aliases;
+my $remote_user = $ENV{SSF_REMOTE_USER} || $ENV{USER};
+
open(my $ssh_config, '<', "$ENV{HOME}/.ssh/config") or die "nope";
while (my $line = <$ssh_config>) {
if ($line =~ /^Host ([^#\n]+)(?: # (.*))?$/) {
@@ -70,9 +72,9 @@ if (exists $ENV{TMUX}) {
# The window does not exist; make the connection in the current one
# and it to the machine we're connecting to
`tmux rename-window $hostname`;
- system 'ssh', '-t', $host, "sh -c \"tmux new -As $ENV{USER}\"";
+ system 'ssh', '-t', $host, "sh -c \"tmux new -As $remote_user\"";
`tmux rename-window '!$hostname'`;
}
} else {
- exec 'ssh', '-t', $host, "sh -c \"tmux new -As $ENV{USER}\"";
+ exec 'ssh', '-t', $host, "sh -c \"tmux new -As $remote_user\"";
}