You can use ssh keys but for simplicity here making the call with a password:<\/strong><\/p>\n\r\n$conn_id = ssh2_connect('server', 22);\r\nssh2_auth_password($conn_id, 'user', 'pwd');\r\n\r\necho("SOLARIS SERVER SNAPSHOTS - CREATION);\r\n$stream=ssh2_exec($conn_id,"\/usr\/sbin\/zfs list -t snapshot -o name,creation | grep $share | grep -v tank");\r\n$outS="";\r\nstream_set_blocking($stream, true);\r\nwhile($o=fgets($stream)){\r\n$outS = $outS . $o;\r\n}\r\nfclose($stream);\r\nprint_snaps_sorted($outS);\r\n<\/pre>\nSlightly more complicated to make up the built-in javascript \"command\" you are passing when using a ZFS appliance.\u00a0<\/strong><\/p>\n\r\n$chk_snaps_cmd="\r\nrun('select DBF');\r\nrun('snapshots');\r\nsnapshots = list();\r\nfor (i = 0; i < snapshots.length; i++) {\r\nrun('select ' + snapshots[i]);\r\ncreation = run('get creation');\r\nprintf('%s %s', snapshots[i],creation);\r\nrun('cd ..');\r\n}";\r\n\r\n$share = $_GET['share'];\r\n$conn_id = ssh2_connect('server', 22);\r\nssh2_auth_password($conn_id, 'user', 'pwd');\r\necho('ZFS STORAGE APPLIANCE SNAPSHOTS - CREATION');\r\n$stream=ssh2_exec($conn_id,"script run('shares select $share');" . $chk_snaps_cmd);\r\nstream_set_blocking($stream, true);\r\nwhile($o=fgets($stream)){\r\n $outS = $outS . $o;\r\n}\r\nfclose($stream);\r\nprint_snaps_sorted($outS);\r\n<\/pre>\nNote:<\/strong> \u00a0I had an issues using ssh calls not returning results when using a non-privileged user whereas a root user worked. \u00a0\u00a0Thanks Matt M for pointing out the obvious. \u00a0I needed to use the full path to the binary in this case \/usr\/sbin\/zfs so most likely some path issue in the user shell.<\/p>\n","protected":false},"excerpt":{"rendered":"PHP can use the bindings to the\u00a0 libssh2\u00a0library which provide access to resources (shell, remote exec, tunneling, file transfer) on<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[19,21],"tags":[],"class_list":["post-472","post","type-post","status-publish","format-standard","hentry","category-php","category-ssh"],"_links":{"self":[{"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/posts\/472","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/comments?post=472"}],"version-history":[{"count":0,"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/posts\/472\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/media?parent=472"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/categories?post=472"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/tags?post=472"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}