It seems that the SSH server on your particular device is not able to handle several requests over the same connection.
I can think of two workarounds for that:
- Open a new connection for every request
- Run a full interactive session on the server and use Expect to drive it (you can also try with Net::SSH::Expect or any of the other modules targeting specific Cisco devices).