i am new to PGP and i am trying to setup a bat file to decrypt my files to load into Automated Task. i was able to put together a bat file that worked however it kept prompting me for a password even though it was included in my bat command. Deeper research i found that gpg-agent needs to allow loopback as mentioned here https://lists.gnupg.org/pipermail/gnupg-devel/2015-May/029851.html So when i include --pinentry-mode loopback it now loops infinitely! If i remove it from my bat statement it still loops infinitely! without decrypting anything. Furthermore i have to force close the window.
Here is the command i am using..
echo MyPassPhrase | gpg -v --batch --yes --pinentry-mode loopback --passphrase-fd 0 --force-mdc -d testing.file.pgp
Even if i use..
gpg -v -o test.txt --force-mdc -d testing.file.pgp
it loops infinitely!
Something is obviously wrong. I am using the GnuPG version 2.2.8. Thinking i should downgrade?? Been having a lot of issues with this version.
Never had any issues using this syntax
gpg --batch --passphrase somepassphrase -o "Outfile.txt" --decrypt "Input.pgp"
Got a couple dozen automated tasks that do this several times a day.
Related
Its almost certain that HTA files are obsolete, but i've found that they are much better than net send / msg.
I'm trying to run a HTA file on a remote machine using PSTools, but instead of it running, it brings back a broken window:
Running the HTA file using CMD (locally) works perfectly though.
My PsExec line:
PsExec.exe -accepteula -i -d \\itwall cmd 'mstha \\intranet\Downloads\VisitorSystemNewMessage.hta asd'
I even tried to run the HTA from a Batch file, but the exact same thing happens.
Any ideas?
It's because the account running the command cannot interact with the session of the remote user.
Use the -s switch to run the HTA using the system account of the remote computer.
Also, you shouldn't need to run cmd. You should be able to just specify mshta.exe then your arguments.
PsExec.exe -accepteula -s -i -d \\itwall mshta.exe \\intranet\Downloads\VisitorSystemNewMessage.hta asd
Edit: To illustrate that this is not an HTA issue. Run the following command:
PsExec.exe -accepteula -i -d \\itwall notepad.exe
Notice you'll have the same black window showing.
I have created a small script that initiates PSEXEC to run a file (a registry key) on a remote computer that is in the domain; however, when I run the script I receive an error indicating that "the system cannot find the file specified."
Below is my script:
#echo off
psexec \\PRECDP19425 -u PRECDP19425\WAKE -p <password> -h -i -d C:\Users\WAKE\Documents\AllowNetwork.reg
pause
I have double-checked the location to make sure I wasn't losing my mind and typed something incorrectly, yet that doesn't seem to be the case. The path is correct, I'm just not sure what is causing the script to fail.
The exact error I receive is:
PsExec could not start C:\Users\etc on PRECDP19425
The system cannot find the file specified.
Any help would be much appreciated.
C:\Users\WAKE\Documents\AllowNetwork.reg is not a valid command line because a .reg file is not an executable, you need to pass it to reg.exe:
REG IMPORT C:\Users\WAKE\Documents\AllowNetwork.reg
This question already has answers here:
psftp.exe get files from the server and delete
(3 answers)
Closed 4 years ago.
I was wondering if someone knows how to do what I'm looking to do.
For my server, I download files from an FTP server daily at 5AM. My batch script is pretty simple, it connects to the FTP server, downloads the files, processes them locally, and then deletes the processed files from the local directory, but I am unable to figure out how to get the batch file to purge only the downloaded files from the server.
Here is the code I'm currently using (edited for privacy)
C:
cd "C:\targetfolder"
rem psftp -b download.cmd -i priv(second).ppk -P 2223 xxx#yyy.ca
psftp -b download(second).cmd -i priv(second).ppk -P 2223 xxx#yyy.ca
rem psftp -b download.cmd -i priv.ppk xxx#yyy.ca
psftp -b download.cmd -i priv.ppk -P 2223 xxx#yyy.ca
rename *.xxx *.xxx
del done*.*
So the script as it is successfully is run every morning and downloads my new files. Are there some line(s) of code I'm missing that will simply delete the downloaded files only?
I also want to mention that I cannot install any new software on my FTP server to manage the files, so it has to be processed in my batch code here.
Thank you in advance for any help you all may be able to provide!
EDIT1: Here is the script in the doanload.cmd
ls
cd target
ls
mget *
Solved, thanks to #MartinPrikryl.
I added "rm *" to the end of my cmd file and it's working nicely, even though it doesn't differentiate from downloaded and non-downloaded files, it does what I need.
Thanks #MartinPrikryl!
I have a .jmx file of all of my test plans and I want to create a batch file. When I click that, everything starts and ends automatically. So that I can provide it to my client as well to verify that I have performed the load test on his website. How can I achieve this?
jmeter does not support running batch of .jmx files as document part 2.4.3 (Command Line Mode) gives to us.
I would recommend you to try 2 approaches:
1) to follow best practices of running jMeter in non GUI mode.
In accordance to this approach you are expected to use the command
jmeter -n -t D:\TestScripts\script.jmx -l D:\TestScripts\scriptresults.jtl
Where the pareameters:
-n [This specifies JMeter is to run in non-gui mode]
-t [name of JMX file that contains the Test Plan]
-l [name of JTL file to log sample results to]
-j [name of JMeter run log file]
2) to use any cloud service for running your .jmx file.
BlazeMeter (http://blazemeter.com/) worked for me fine.
One can adjust the test plan settings.
Testing results can be seen on “Load Report” tab as soon as test finishes.
For detalization one can follow Getting Started: Scripting with JMeter steps.
Hope this works for you.
Just write the following command in a text file and save this file as SomeName.bat
#ECHO OFF
jmeter -n -t "Your .jmx file path" -l "Your .jtl file path"
For example:
#echo off
jmeter -n -t F:\DEV\WORKSPACE\buyer.jmx -l F:\DEV\WORKSPACE\output.jtl
After saving click on that bat file. The test plan result will be stored into .jtl file.
Note: Make sure you put this bat file into JmeterinstallationDirectory/bin folder.
I'm trying to download a file from sftp site using batch script. I'm getting the following error:
Permission denied (publickey,password,keyboard-interactive).
Couldn't read packet: Connection reset by peer
When running the command:
sftp -b /home/batchfile.sftp <user>#<server ip>:<folder>
the batchfile.sftp includes these data:
password
lcd [local folder]
cd [sftp server folder]
get *
bye
Note: It's working when running at the prompt as
sftp <user>#<server ip>:<folder>
But I need the ability to enter the password automatically.
You'll want to install the sshpass program. Then:
sshpass -p YOUR_PASSWORD sftp -oBatchMode=no -b YOUR_COMMAND_FILE_PATH USER#HOST
Obviously, it's better to setup public key authentication. Only use this if that's impossible to do, for whatever reason.
If you are generating a heap of commands to be run, then call that script from a terminal, you can try the following.
sftp login#host < /path/to/command/list
You will then be asked to enter your password (as per normal) however all the commands in the script run after that.
This is clearly not a completely automated option that can be used in a cron job, but it can be used from a terminal.
I advise you to run sftp with -v option. It becomes much easier to fathom what is happening.
The manual clearly states:
The final usage format allows for automated sessions using the -b
option.
In such cases, it is necessary to configure non-interactive authentication
to obviate the need to enter a password at connection time (see
sshd(8) and ssh-keygen(1) for details).
In other words you have to establish a publickey authentication. Then you'll be able to run a batch script.
P.S.
It is wrong to put your password in your batch file.
You mention batch files, am I correct then assuming that you're talking about a Windows system? If so you cannot use sshpass, and you will have to switch to a different option.
Two of such options, that follow diametrically opposite philosophies are:
psftp: command-line tool that you can call from within your batch scripts; psftp is part of the PuTTY package and you can find it here http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html
Syncplify.me FTP Script: a scriptable FTP/S and SFTP client for Windows that allows you to store your password in encrypted "profile files"; check it out here http://www.syncplify.me/products/ftp-script/
Either way, switching from password to PKI authentication is strongly recommended.
PSFTP -b path/file_name.sftp user#IP_server -hostkey 1e:52:b1... -pw password
the file content is:
lcd "path_file for send"
cd path_destination
mput file_name_to_send
quit
to have the hostkey run:
psftp user#IP_SERVER
You need to use the command pscp and forcing it to pass through sftp protocol. pscp is automatically installed when you install PuttY, a software to connect to a linux server through ssh.
When you have your pscp command here is the command line:
pscp -sftp -pw <yourPassword> "<pathToYourFile(s)>" <username>#<serverIP>:<PathInTheServerFromTheHomeDirectory>
These parameters (-sftp and -pw) are only available with pscp and not scp. You can also add -r if you want to upload everything in a folder in a recursive way.
This command will help you
sshpass -p MYPASSWORD sftp MYUSERNAME#HOST