Hello all,
I'm trying to do something that should be simple but for some reason, I guess I'm just bored and making it difficult. I'm trying to run a command on a remote computer via SSH. The remote computer has the port changed for SSH and I need to use a key to connect. I first tried Net::SSH::Perl but I kept running into the "Received disconnect message: Too many authentication failures for abc at ~ ~ ~ AuthMgr.pm line 143. I see many people have had trouble with it so I moved on to something else like below. When I run this, I get "Undefined subroutine &main::ssh_cmd called at ./3test.pl line 3.". Net::SSH::Expect just seems to be overkill for something this simple. Can someone give me a hand on this?
Thank you.
#!/usr/bin/perl
use Net::SSH qw(ssh issh sshopen2 sshopen3);
ssh_cmd ({
user => 'root',
host => '192.168.1.2',
command => "chmod 777 /var/named/zzz.z",
args => ["-i /root/.ssh/thispc-ssh-key", "-P 33"],
stdin_string => "string\n",
});
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|