How can I ssh inside a Perl script?

后端 未结 9 1060
猫巷女王i
猫巷女王i 2020-12-09 12:14

I want to SSH to a server and execute a simple command like \"id\" and get the output of it and store it to a file on my primary server. I do not have privileges to install

9条回答
  •  半阙折子戏
    2020-12-09 12:46

    If you're using backticks try this:

    my @output = `ssh root@1.1.1.1 "which perl"`;
    
    print "output: @output";
    

    This is only useful if you have a publickey that the above command won't prompt for password.

提交回复
热议问题