Recommendations on pulling, on-demand, a file from SSH session? I have a remote device, that I have only SSH access to, I need to connect via SSH, pull a file over the connection, then of course close the SSH session.
I can see or envision various ways to do this, that would be better than using SSH, but I can't touch the remote device, i.e. I can install anything or script anything. Frankly, I would rather implement a script and cron-tab job on the device and just have NR watch/listen for the transport, but that is not an option in this case.
Yeah, keys are no problem that I can do fortunately. I can't use SFTP per se, since it is not native to the device, but SSH is. This is pulling statistics and configuration data from a remote router. I don't believe rsync is present, I will need to check on that. I was thinking SCP as well, but never hurts to ask what others have done.
I discover this evening that I might be able to use the REST API that the documentation suggests is native to the router OS, if that is enabled/in place that might be an option as well.
Unfortunately, SNMP was the first thing I looked at, then the REST API, neither give specific visibility to the DHCP lease information. I got the administration team to make the issue a bit more manageable, in that I got them to segment the log files, geez which they should have been doing anyway... but I digress, so I have the key information isolated to a specific file, now I just need to grab it, parse a bit, and present it, and since NR has a lot of flexibility to present data, well, preaching to the choir at this point right? The router technology is better than consumer grade but not as robust as Cisco... where the custom OIDs would make this almost painless. Why is all this important? Well with the significant increase in wireless use, the rather poor auditing available, etc., etc. The entity is small, so does not have a robust budget. Time to get creative.
Love it, I thinking about using python in fact, very timely! I just finished revising my python MQTT based "Listener" that responds to NR requests on/to ESP based IoT devices, Raspberry Pi devices, etc. A few days I should have one of the new Pi Pico with integrated WiFi devices, to develop my "Listener" on using micro-python or Circuit-Python on.
Well, from wiki, outdated but for me you may use whatever
According to OpenSSH developers in April 2019, SCP is outdated, inflexible and not readily fixed; they recommend the use of more modern protocols like SFTP and rsync for file transfer. As of OpenSSH version 9.0, scp client therefore uses SFTP for file transfers by default instead of the legacy SCP/RCP protocol.
This is the second or third time I have seen this referenced that SCP is now dead. And yet, I often see if recommended by audit teams and security teams still for one-off transport. Clearly SCP is still tested and actively evaluated by many. I have no strong position just pointing out that SCP is still used. Given use of VPNs, encrypted file level compression methods, and other layered security (stacks) I am sure SCP is still used because it is easy and straight-forward, say compared to rsync for example. I don't think anyone would use SCP now, as secure transport, as it was once was. The issue with SFTP is the (negative) association with former FTP. I know for a fact, that one Fortune 10 company has banned SFTP simply because it is associated with FTP. The internal security team is just not listening or acknowledging the difference. Again, I just pointing out my experience, not voicing any option. Just as a foot note, ROBOCOPY has not been updated since Windows 2000 server or so as I recall, and yet it is still used among Windows administrators extensively even now.
I would have originally suggested rsync, but it may not be installed on the remote machine, so I did not suggest that.
scp is perfectly good and adequate if the requirement is just to transfer a small file. It is secure and is not going to disappear in the foreseeable future. If rsync is available then by all means use that.
When I asked about the advantage over scp I was referring to writing a python script to do the same thing, which seems pointless.
Right, I understood your intent about python. Given my long history with python, it was passing thought, and a fall back if needed, but with various other options, not likely.
I am checking on rsync... given the router is a customized version of Debian, it might be there.
The bummer is that the dhcp information now isolated, is in a 'user' file system, which as far, as I have found as yet, is not visible to the REST API. Which seems odd. I have a query to the router OS team of the vendor to ask about this. They have a REST API that can capture the entire 'config' state of the router which is its own file system, so I suspect the REST API could be amended with little effort to expose the 'user' file system. The trick is to get the vendor to see that.