This is simple job for AppleScript. First off make sure you're redirecting the standard output to a file by doing sudo security dump-keychain -d login.keychain > ~/Desktop/loginKeychain.txt
. Before doing this command open up Script Editor, it should be in /Applications/Utilities/
then paste this:
tell application "System Events"
repeat while exists (processes where name is "SecurityAgent")
tell process "SecurityAgent"
click button "Allow" of window 1
end tell
delay 0.2
end repeat
end tell
Now start the dump command, then click the Play button at the top of the Script Editor. This should press the buttons.
The Allow Always gives the permission to access keychain item forever, but it's only applied on one item at a time. I would stick with clicked Allow so someone else cannot access it in future without your permission.
sudo
.