in reply to Calling a remote ssh connection from perl

> ssh: Could not resolve hostname root.remoteIP: Name or service not known

are you sure you are showing us the right code and error message?

This

system("ssh root@remoteIP /usr/bin/ls");

will try to interpolate an array @remoteIP into the double-quoted string

so better either write

system("ssh root\@remoteIP /usr/bin/ls")

or

system('ssh root@remoteIP /usr/bin/ls')

BTW: did you use strict and warnings ?

HTH! :)

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery

Replies are listed 'Best First'.
Re^2: Calling a remote ssh connection from perl
by KenHorse (Initiate) on May 27, 2021 at 22:43 UTC
    Yes, I forgot to escape from things. So I modified the command
    system("ssh root\@remoteIP /usr/bin/ls");

    and that seems to connect to the remote server but now it prompts for the password. And when I enter the password, I get a Permission Denied error.

      see haukex' suggestion to use Net::OpenSSH, I second this.

      And you've changed the original post I replied to, this makes reading and understanding the thread very hard for others.

      (it was system("ssh root@remoteIP /usr/bin/ls"); )

      Cheers Rolf
      (addicted to the Perl Programming Language :)
      Wikisyntax for the Monastery