Unable unzip file with the correct password - zip

Before i used command "zip -eq file.zip /folder" to zip my folder with the password.
Now I unzip the file with the correct password but always show "Wrong password".
I also tried to use PassFab to check but strange. It note my zip file is unencrypted and doesn't have password.
Anyone face this issue or any ideas?

Related

How do I pass username and password with a wget.download() request in Python3

To download a file from a web server, I do below -
import wget
url = "https:xxxxx/file"
iso_filename = wget.download(url, '/Users/xxxxx/Downloads/')
Now, I am trying to download a file from a website which requires authentication.
User credentials involve special characters - #, # etc
I would like to know a way of how to supply username and password in python3 while using wget ?
I would prefer to use wget unless there isn't any other option to overcome this issue.
Any advise would be highly appreciated.
I finally gave up on using wget.download(), what worked for me is scp, explained as below -
sshpass -f 'path to psw file' scp -r user#10.X.X.X:/file_path /path_to dowload_file
ex:
sshpass -f 'usr/bin/psw.txt' scp -r user#10.X.X.X:/usr/bin/ubuntu.iso /remote/user/iso
psw.txt to pass password in a file to avoid been listed in bash history etc...

How to take user input or prompt dialog for user while installing rpm in spec file

I need to take user-name and password from user while installing rpm. I have tried to ask user input in %post scriplet but its not working.
RPM installation is not interactive. So, you won't be able to read input from the user during RPM installation.
But if you do want to provide input during RPM installation, you can write username and password in a file say "/tmp/credentials.txt" and read this file during RPM install.
Finally I found it myself . You can use like this and it worked fine.....
echo "**********Please enter password**********">/dev/tty
if exec </dev/tty; then
read -s pwd
fi
%global password $pwd

SFTP - WinSCP: Zip a file/folder

I'm transferring a file to SFTP and then trying to zip it with WinSCP. It's not working.
After my put command, I'm using the following command.
zip -r "!?&SFTP Folder Path\MyFile.txt:?SFTP Folder Path\MyFile.zip!" !&
What am I doing wrong? What should I be doing? If I only want to zip a/any file with specific extension or folder, what changes do I make?
Update:
I'm getting the following log output after a file has been copied over to the sftp
...
batch continue Searching for host...
Connecting to host...
Authenticating...
Using username "admin". Authenticating with pre-entered password. Authenticated. Starting the session...
I'm using the following code after put cmd line.
option batch continue
call zip -r "/sftp folder/Myfile.zip" Myfile.csv
close
exit
Your syntax is a custom command. The custom commands is a GUI feature of WinSCP, it has nothing to do with the scripting.
In WinSCP scripting use the call command.
call zip -r /path/MyFile.zip file1.dat file2.dat ...
Though make sure you are allowed to execute shell commands on the server.

Need to Transfer Files from One Linux Machine to Other Linux Machine via SFTP

I have created a very small script below which i want help me to move files from one server to other server periodically via cronjob.
#!/bin/sh
HOST='1.1.1.1'
FILE='EndpointUsage*.*'
PASS='password#'
sftp kingadmin#$HOST
password $PASS <<END_SCRIPT
binary
lcd /var/tmp/
mput $FILE
quit
END_SCRIPT
Problem i am facing.
1) I need this script to give the password automatically, i do not want to give password manually whenever this script run. Currently when i ran the commands its asking for password as below.
LA:/var/tmp # ./portmove.sh
kingadmin#1.1.1.1's password:
2) I want to send the files to particular directory on remote server. Can you please help how to put the locations in the script so that my script can send the files to particular directory let say in every 10 minutes(which i can configure in cronjob)
Thanks you in advance.
Instead of using a password, consider using a public/private key pair.
You can then specify the key file instead of a password.

Mysqldump launched by cron and password security

I wrote a script to backup my MySQL databases using:
mysqldump --opt --all-databases -u user -pmypassword > myDump.sql
A cron launches it every night and scp the result to another server.
mypassword appears in clear in my script, everyone can see it with the appropriate rights. I have been told about /proc issues too (where the cmd run can be seen).
MySQL documentation says:
Specifying a password on the command line should be considered insecure. See Section 7.6, "Keeping Your Password Secure".
I have not found this magic 7.6 sections anywhere.
What is the good practice to deal with automatic mysqldump and password security?
Quoting the MySQL docs(http://dev.mysql.com/doc/refman/5.1/en/password-security-user.html):
Store your password in an option file. For example, on Unix you can list your password in the [client] section of the .my.cnf file in your home directory:
[client]
password=your_pass
To keep the password safe, the file should not be accessible to anyone but yourself. To ensure this, set the file access mode to 400 or 600. For example:
shell> chmod 600 .my.cnf
To name from the command line a specific option file containing the password, use the --defaults-file=file_name option, where file_name is the full path name to the file.
to add to Sahil's answer above, use --defaults-extra-file
--defaults-extra-file
is used to tell a program to read a single specific option file in addition to the standard option files.
whereas --defaults-file is read instead of the default my.cnf file.
The accepted answer stores the password in a plain text file, which could be read by anyone with administrative (root) access. If your database is in a shared hosting environment, this is undesirable.
A better option would be to use mysql_config_editor to create an encrypted login path named mysqldump. According to the MySQL documentation:
mysql_config_editor encrypts the .mylogin.cnf file so it cannot be read as cleartext, and its contents when decrypted by client programs are used only in memory. In this way, passwords can be stored in a file in non-cleartext format and used later without ever needing to be exposed on the command line or in an environment variable.
The following command will create your mysqldump login path:
mysql_config_editor set --login-path=mysqldump --host=your_hostname --user=your_username --password
You will be prompted to enter your password, and the login path you created will be stored in encrypted format. mysqldump will automatically use this login path whenever you call it in the future, unless you specify a different login path with the --login-path command line option.
Here is how you would invoke mysqldump after creating an encrypted login path:
mysqldump database_name > output_file
All answers here are in pieces so sharing a complete command which will do the required and must be used if database are heavy in size, --single-transaction and --lock-tables are very important here
mysqldump --defaults-extra-file=/home/dangi/.my.cnf -u root --single-transaction --quick --lock-tables=false --all-databases (or) DATABASE | gzip > OUTPUT.gz;
Note: Answer is in add of Avibodha and sahil answer, they have already made the point. I am just putting their answer in single piece of code with important measure should be taken at time of backing up live database
Check out Keeping Passwords Secure for a good answer. You can store your password in the my.cnf file changing the permissions on that file to keep the password secure.
You can also check the last comment on this page too:
MYSQL_PWD="tinkerbell" mysqldump -ubackup --all-databases > dump.sql
The following method works for me on a Windows machine, if you have 2 versions of MySQL installed, and you are not sure which my.ini is used when you run mysqldump, this will also help:
1, C:\ProgramData\MySQL\MySQL Server 5.6\my.ini, fine [client], replace it to:
[client]
user=my_user
password=my_password
2, Use this command:
C:\Program Files\MySQL Server 5.6\bin>mysqldump --default-extra-file="C:\ProgramData\MySQL\MySQL Server 5.6\my.ini" -u my_user db_to_export > db_to_export.sql

Resources