Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

Once you're logged into the subsytem, you get a hello message like this:

<?xml version="1.0" encoding="ISO-8859-1"?> <hello xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"> <capabilities> <capability>urn:ietf:params:xml:ns:netconf:base:1.0</capability> <capability>urn:ietf:params:netconf:base:1.0</capability> </capabilities> <session-id>25470</session-id> </hello> ]]>]]>

You reply with a client hello message that is formatted very similarly, and then you send it XML/NETCONF formatted messages and it replies with XML formatted responses.

Using your suggestion, I tried this:

my $ssh = Net::OpenSSH->new($host, user=>$user, password=>$pass); $ssh->error and die "unable to connect to remote host: " . $ssh->error +; my ($socket, $pid) = $ssh->open2socket({ssh_opts => '-s'}, 'xmlagent') +; ($socket, $pid) = $ssh->open2socket; while (<$socket>) { print }; waitpid($pid, 0);

Expecting to either see the XML hello message in the debug, or in the socket print. However, it appears that it first makes a connection to the main system, authenticates, and then tries to connect to the subsystem. I'm not good enough with SSH to know if that's how it works with except/shell version or not. Debug shows this:

# call args: ['ssh','-o','ServerAliveInterval=30','-x2MN','-o','Number +OfPasswordPrompts=1','-o','PreferredAuthentications=keyboard-interact +ive,password','-S','/home/user/.libnet-openssh-perl/user-host-31054-2 +7407','-l','user','host','--']

Then I see the banner go by and the password prompt as expected, but no XML hello. Then I see:

# call args: ['ssh','-s','-S','/home/user/.libnet-openssh-perl/user-ho +st-31054-27407','-l','user','host','--','xmlagent'] # open_ex: ['ssh','-s','-S','/home/user/.libnet-openssh-perl/user-host +-31054-27407','-l','user','host','--','xmlagent'] # call args: ['ssh','-S','/home/user/.libnet-openssh-perl/user-host-31 +054-27407','-l','user','host','--'] # open_ex: ['ssh','-S','/home/user/.libnet-openssh-perl/user-host-3105 +4-27407','-l','user','host','--'] Pseudo-terminal will not be allocated because stdin is not a terminal. stty: standard input: Invalid argument

And then it hangs there, probably looping on the "while". But, the important bit for this step is that it does not look this this creates a properly formatted SSH command either. The "-s" flag is at the beginning, but the "xmlagent" value is at the end - I would expect that it would need to send "-s xmlagent" in order for the -s flag to have meaning. I'm also suspecting that it needs to do so in the first connection, not later (but I'm not positive if that is how SSH should work or not).


In reply to Re^2: SSH to remote subsystem (Net::OpenSSH?) by sojourner9
in thread SSH to remote subsystem (Net::OpenSSH?) by sojourner9

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • 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.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (6)
As of 2024-04-23 06:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found