I have a script that I need to add to copy the Syslog from Linux. When I use PSCP.exe for this it works perfectly unless the RSA is unknown.
When the RSA key is known this works perfectly.
cmd.exe /c pscp -pw 12345678 -P 22 root@10.10.10.10:/var/log/syslog $file
I get the following error when the RSA isn’t known and locks the script.
cmd.exe : The server’s host key is not cached in the registry. You
-
- CategoryInfo : NotSpecified: (The server’s ho…e registry. You:String) , RemoteException
- FullyQualifiedErrorId : NativeCommandError
have no guarantee that the server is the computer you
think it is.
The server’s ssh-ed25519 key fingerprint is:
ssh-ed25519
If you trust this host, enter “y” to add the key to
PuTTY’s cache and carry on connecting.
If you want to carry on connecting just once, without
adding the key to the cache, enter “n”.
If you do not trust this host, press Return to abandon the
connection.
I can add the -batch switch at the script will keep running, but everything I have tried will not automate a yes, or ask for a yes or no.
Here is the full portion of the script.
#Prompt for IP</code> <code>$LinuxIP = read-host -prompt "Linux IP"</code> <code>if(Test-Connection $LinuxIP -Count 1 -Quiet){</code> <code>$status='True'</code> <code>Write-Host $LinuxIP is Online -ForegroundColor Green</code> <code>cmd.exe /c pscp -pw 123456 -P 22 -batch "root@${LinuxIP}:/var/log/syslog" ".\Files\AS"</code> <code>}else{$status='False'</code> <code>Write-Host $LinuxIP is Offline -ForegroundColor Red</code> <code>}
Is this possible in Powershell Version : 5.1.19041.610?