3 # get_remote_ip: Get IP address (or hostname) of the host from which this SSH
5 # Usage: get_remote_ip [-n]
10 my $ip = $ENV{SSH_CLIENT};
13 $ip =~ s/\s.*//; $ip =~ s/^::ffff://;
14 unless ($ARGV[0] eq "-n") {
19 my $name = gethostbyaddr(inet_aton($ip), AF_INET);
20 if ($name) { $name =~ s/\..*//; print "$name\n"; } else { print "$ip\n" }