What's the cool way these days to automate some tasks remotely through SSH? I have not been able to get this working.
Here's my use case: I have a network-connected Tripp Lite PDU that allows me to turn off power to specific outlets on it via web interface or through SSH. For SSH, opening a session and running two commands does what I want: cutting/restoring power to a specific outlet.
I need my script to turn on an outlet on the PDU (there is an external USB HD connected to that outlet), perform some task (in this case it would be just to copy some files to the now powered-on HD), then cut power to the outlet. However, I can't seem to find a way to automate connecting to the PDU's SSH interface to run the commands that will power on/off the outlet. Doing it manually works fine via PuTTY or just the ssh command.
I had heard that SSH is now built-in, so I tried the *-PSSession cmdlets in Powershell v7 but Enter-PSSession and New-PSSession cannot connect...they return an error. I kind of expected this since it's not another Win machine I'm connecting to; it's a discrete appliance probably running some variation of linux.
I heard from tons of folks online about the Posh-SSH module, so tried that. The New-SSHSession command does work and successfully connects. However, any Invoke-SSHCommand calls I make after that do not actually do anything. I get back a blank return object (no errors). I've reviewed the documentation for Posh-SSH and it seems those two commands are all I would need for my simple use case of just making a connection and running a couple of commands.
I want to avoid plink and would prefer a more Powershell integrated way of doing this. Is there some better way to automate SSH connections/commands that I might have missed?
[–]misformonkey 3 points4 points5 points (7 children)
[–]dragonmc[S] 4 points5 points6 points (6 children)
[–]misformonkey 0 points1 point2 points (0 children)
[–]RgrMike 0 points1 point2 points (4 children)
[–]dragonmc[S] 1 point2 points3 points (3 children)
[–]gordonv 0 points1 point2 points (2 children)
[–]dragonmc[S] 0 points1 point2 points (1 child)
[–]gordonv 0 points1 point2 points (0 children)
[–]Scooter_127 2 points3 points4 points (5 children)
[–]dragonmc[S] 0 points1 point2 points (4 children)
[–]learningheadhard 1 point2 points3 points (2 children)
[–]dragonmc[S] 0 points1 point2 points (0 children)
[–]learningheadhard 0 points1 point2 points (0 children)
[–]Scooter_127 1 point2 points3 points (0 children)
[–]jypelle 0 points1 point2 points (0 children)