{
    "content": [
        {
            "type": "text",
            "text": "# Net::SSH (perldoc)\n\n## NAME\n\nNet::SSH - Perl extension for secure shell\n\n## SYNOPSIS\n\nuse Net::SSH qw(ssh sshcmd issh sshopen2 sshopen3);\nssh('user@hostname', $command);\nissh('user@hostname', $command);\nsshcmd('user@hostname', $command);\nsshcmd( {\nuser => 'user',\nhost => 'host.name',\ncommand => 'command',\nargs => [ '-arg1', '-arg2' ],\nstdinstring => \"string\\n\",\n} );\nsshopen2('user@hostname', $reader, $writer, $command);\nsshopen3('user@hostname', $writer, $reader, $error, $command);\n\n## DESCRIPTION\n\nSimple wrappers around ssh commands.\n\n## Sections\n\n- **NAME**\n- **SYNOPSIS**\n- **DESCRIPTION**\n- **SUBROUTINES**\n- **EXAMPLE**\n- **FREQUENTLY ASKED QUESTIONS**\n- **GENERATING AND USING SSH KEYS**\n- **AUTHORS**\n- **COPYRIGHT**\n- **BUGS**\n- **SEE ALSO**\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "Net::SSH",
        "section": "",
        "mode": "perldoc",
        "summary": "Net::SSH - Perl extension for secure shell",
        "synopsis": "use Net::SSH qw(ssh sshcmd issh sshopen2 sshopen3);\nssh('user@hostname', $command);\nissh('user@hostname', $command);\nsshcmd('user@hostname', $command);\nsshcmd( {\nuser => 'user',\nhost => 'host.name',\ncommand => 'command',\nargs => [ '-arg1', '-arg2' ],\nstdinstring => \"string\\n\",\n} );\nsshopen2('user@hostname', $reader, $writer, $command);\nsshopen3('user@hostname', $writer, $reader, $error, $command);",
        "tldr_summary": null,
        "tldr_examples": [],
        "tldr_source": null,
        "flags": [],
        "examples": [
            "use Net::SSH qw(sshopen2);",
            "use strict;",
            "my $user = \"username\";",
            "my $host = \"hostname\";",
            "my $cmd = \"command\";",
            "sshopen2(\"$user\\@$host\", *READER, *WRITER, \"$cmd\") || die \"ssh: $!\";",
            "while (<READER>) {",
            "chomp();",
            "print \"$\\n\";",
            "close(READER);",
            "close(WRITER);"
        ],
        "see_also": [
            {
                "name": "ssh-keygen",
                "section": "1",
                "url": "https://www.chedong.com/phpMan.php/man/ssh-keygen/1/json"
            },
            {
                "name": "ssh",
                "section": "1",
                "url": "https://www.chedong.com/phpMan.php/man/ssh/1/json"
            }
        ],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 19,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 5,
                "subsections": []
            },
            {
                "name": "SUBROUTINES",
                "lines": 26,
                "subsections": []
            },
            {
                "name": "EXAMPLE",
                "lines": 17,
                "subsections": []
            },
            {
                "name": "FREQUENTLY ASKED QUESTIONS",
                "lines": 13,
                "subsections": []
            },
            {
                "name": "GENERATING AND USING SSH KEYS",
                "lines": 33,
                "subsections": []
            },
            {
                "name": "AUTHORS",
                "lines": 18,
                "subsections": []
            },
            {
                "name": "COPYRIGHT",
                "lines": 4,
                "subsections": []
            },
            {
                "name": "BUGS",
                "lines": 4,
                "subsections": []
            },
            {
                "name": "SEE ALSO",
                "lines": 11,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "Net::SSH - Perl extension for secure shell\n",
                "subsections": []
            },
            "SYNOPSIS": {
                "content": "use Net::SSH qw(ssh sshcmd issh sshopen2 sshopen3);\n\nssh('user@hostname', $command);\n\nissh('user@hostname', $command);\n\nsshcmd('user@hostname', $command);\nsshcmd( {\nuser => 'user',\nhost => 'host.name',\ncommand => 'command',\nargs => [ '-arg1', '-arg2' ],\nstdinstring => \"string\\n\",\n} );\n\nsshopen2('user@hostname', $reader, $writer, $command);\n\nsshopen3('user@hostname', $writer, $reader, $error, $command);\n",
                "subsections": []
            },
            "DESCRIPTION": {
                "content": "Simple wrappers around ssh commands.\n\nFor an all-perl implementation that does not require the system ssh command, see Net::SSH::Perl\ninstead.\n",
                "subsections": []
            },
            "SUBROUTINES": {
                "content": "ssh [USER@]HOST, COMMAND [, ARGS ... ]\nCalls ssh in batch mode.\n\nissh [USER@]HOST, COMMAND [, ARGS ... ]\nPrints the ssh command to be executed, waits for the user to confirm, and (optionally)\nexecutes the command.\n\nsshcmd [USER@]HOST, COMMAND [, ARGS ... ]\nsshcmd OPTIONSHASHREF\nCalls ssh in batch mode. Throws a fatal error if data occurs on the command's STDERR.\nReturns any data from the command's STDOUT.\n\nIf using the hashref-style of passing arguments, possible keys are:\n\nuser (optional)\nhost (required)\ncommand (required)\nargs (optional, arrayref)\nstdinstring (optional) - written to the command's STDIN\n\nsshopen2 [USER@]HOST, READER, WRITER, COMMAND [, ARGS ... ]\nConnects the supplied filehandles to the ssh process (in batch mode).\n\nsshopen3 HOST, WRITER, READER, ERROR, COMMAND [, ARGS ... ]\nConnects the supplied filehandles to the ssh process (in batch mode).\n",
                "subsections": []
            },
            "EXAMPLE": {
                "content": "use Net::SSH qw(sshopen2);\nuse strict;\n\nmy $user = \"username\";\nmy $host = \"hostname\";\nmy $cmd = \"command\";\n\nsshopen2(\"$user\\@$host\", *READER, *WRITER, \"$cmd\") || die \"ssh: $!\";\n\nwhile (<READER>) {\nchomp();\nprint \"$\\n\";\n}\n\nclose(READER);\nclose(WRITER);\n",
                "subsections": []
            },
            "FREQUENTLY ASKED QUESTIONS": {
                "content": "Q: How do you supply a password to connect with ssh within a perl script using the Net::SSH\nmodule?\n\nA: You don't (at least not with this module). Use RSA or DSA keys. See the quick help in the\nnext section and the ssh-keygen(1) manpage.\n\nA #2: See Net::SSH::Expect instead.\n\nQ: My script is \"leaking\" ssh processes.\n\nA: See \"How do I avoid zombies on a Unix system\" in perlfaq8, IPC::Open2, IPC::Open3 and\n\"waitpid\" in perlfunc.\n",
                "subsections": []
            },
            "GENERATING AND USING SSH KEYS": {
                "content": "1 Generate keys\nType:\n\nssh-keygen -t rsa\n\nAnd do not enter a passphrase unless you wanted to be prompted for one during file copying.\n\nHere is what you will see:\n\n$ ssh-keygen -t rsa\nGenerating public/private rsa key pair.\nEnter file in which to save the key (/home/User/.ssh/idrsa):\nEnter passphrase (empty for no passphrase):\n\nEnter same passphrase again:\n\nYour identification has been saved in /home/User/.ssh/idrsa.\nYour public key has been saved in /home/User/.ssh/idrsa.pub.\nThe key fingerprint is:\n5a:cd:2b:0a:cd:d9:15:85:26:79:40:0c:55:2a:f4:23 User@JEFF-CPU\n\n2 Copy public to machines you want to upload to\n\"idrsa.pub\" is your public key. Copy it to \"~/.ssh\" on target machine.\n\nPut a copy of the public key file on each machine you want to log into. Name the copy\n\"authorizedkeys\" (some implementations name this file \"authorizedkeys2\")\n\nThen type:\n\nchmod 600 authorizedkeys\n\nThen make sure your home dir on the remote machine is not group or world writeable.\n",
                "subsections": []
            },
            "AUTHORS": {
                "content": "Ivan Kohler <ivan-netsshpod@420.am>\n\nAssistance wanted - this module could really use a maintainer with enough time to at least\nreview and apply more patches. Or the module should just be deprecated in favor of\nNet::SSH::Expect or made into an ::Any style compatibility wrapper that uses whatver\nimplementation is available (Net::SSH2, Net::SSH::Perl or shelling out like the module does\nnow). Please email Ivan if you are interested in helping.\n\nJohn Harrison <japh@in-ta.net> contributed an example for the documentation.\n\nMartin Langhoff <martin@cwa.co.nz> contributed the sshcmd command, and Jeff Finucane\n<jeff@cmh.net> updated it and took care of the 0.04 release.\n\nAnthony Awtrey <tony@awtrey.com> contributed a fix for those still using OpenSSH v1.\n\nThanks to terrence brannon <tbone@directsynergy.com> for the documentation in the GENERATING AND\nUSING SSH KEYS section.\n",
                "subsections": []
            },
            "COPYRIGHT": {
                "content": "Copyright (c) 2004 Ivan Kohler. Copyright (c) 2007-2008 Freeside Internet Services, Inc. All\nrights reserved. This program is free software; you can redistribute it and/or modify it under\nthe same terms as Perl itself.\n",
                "subsections": []
            },
            "BUGS": {
                "content": "Not OO.\n\nLook at IPC::Session (also fsh, well now the native SSH \"master mode\" stuff)\n",
                "subsections": []
            },
            "SEE ALSO": {
                "content": "For a perl implementation that does not require the system ssh command, see Net::SSH::Perl\ninstead.\n\nFor a wrapper version that allows you to use passwords, see Net::SSH::Expect instead.\n\nFor another non-forking version that uses the libssh2 library, see Net::SSH2.\n\nFor a way to execute remote Perl code over an ssh connection see IPC::PerlSSH.\n\nssh-keygen(1), ssh(1), IO::File, IPC::Open2, IPC::Open3\n",
                "subsections": []
            }
        }
    }
}