GPG - Command to Encrypt contents of folder - All files - pgp

I'm trying to encrypt all the files in folder C:\TEST
What is the command to encrypt all the files in C:\TEST using key email#gmail.com to a new file TEST.GPG
GPG.EXE --encrypt C:\TEST email#gmail.com ??
thx

Related

FTP transfer issue

I am building FTP bash script to generate a .csv file and transfer from a Linux machine to another server, but i have problems because it tigers an error and the file is not transferred on the 2nd server. What could be the problem?
This is the error:
TEST: A file or directory in the path name does not exist.
Filename invalid
And it doesn't matter if i put the / before the TEST, it will trigger the same issue.
This is my script
HOST='ipadress'
USER='user'
PASSWD=''
TARGET='TEST'
#Paramenters
set -x
DATE=`date +%Y%m%d%H%M`
SQL=/home/sql_statement.sql
QUERYCMD=/home/report.sh
CSV=/home/csv/test_$DATE.csv
#Interogate the sql and put in the folder
$QUERYCMD ${SQL} ${CSV}
#Send the .csv file in the target folder
cd /home/csv
ftp -n $HOST <<EOF
quote USER $USER
quote PASS $PASSWD
lcd $TARGET
put $CSV $TARGET
quit
EOF
exit 0
does the symbol TARGET refer to a dir on the remote host?
ftp command lcd would change-dir on the local (client) side, while cd would change-dir on the remote (server) side; also for the remote side there's usually a designated ftp root dir, adjust any path in relation to that starting point; to confirm dir contents, you might add ftp commands ls and !ls on separate lines right after the PASS line

Encrypt a passsword using a pentaho job and store in file

here i have to create a job which coverts the plain text to encrypted password using below syntax
Windows:
Encr.bat -kettle <password>
Linux:
./encr.sh -kettle '<your-password>'
Note: the main problem I'm facing is i have to execute these commands inside data-integration folder alone.
Please hemp me out in this.
here i'm not sure of the location where its in server.
I tried to find the location of the folder using find command
./encr.sh -kettle '<your-password>
have to find the exact location of data-integration folder and execute command line command in this folder path
You can find the file executing this command:
Linux:
find / -name encr.sh
Windows:
dir encr.sh /s /p
Hope this helps.

Shell script to move files on remote SFTP Server

I am trying to move files from one directory to another directory on the remote SFTP Server through shell script after downloading files locally. I understand that there is no wildcard move files function, so it seems that my only option is to rename files individually.
Can someone help me with the code below if there is a better way of writing this code.
All i am trying to do is move files to archive directory on the SFTP Server, once files are downloaded to my local directory.
I know there are other ways to do it with python/perl scripts but i am restricted to use Shell scripting on linux box.
#!/usr/bin/ksh
#LOGGING
LOGFILE="/tmp/test.log"
#SFTP INFO
FTP_SERVER="test.rebex.net"
FTP_USER="demo"
FTP_PWD="password"
FTP_PORT=22
FTP_PICKUP_DIR="/"
LOCAL_DIR="/"
#-------DOWNLOAD FILES
expect <<END #> $LOGFILE
send "$(date)\r";
spawn sftp $FTP_USER#$FTP_SERVER
expect "*password: "
send "$FTP_PWD\r";
expect "sftp> "
send "mget *.ext\r"
expect "sftp>"
send "exit\r"
END
#--------- MOVE FILES TO ARCHIVE ON SERVER
cd /home/ravi/Files
for fl in *.ext
do
expect <<END #> $LOGFILE
send "$(date)\r";
spawn sftp $FTP_USER#$FTP_SERVER
expect "*password: "
send "$FTP_PWD\r";
expect "sftp> "
send "rename $fl /ARCHIVE/$fl\r"
expect "sftp>"
send "exit\r"
END
done
#For Loop End
you can use lftp with mmv option
mmv [-O directory] file(s) directory
Move specified files to a target directory. The target directory can be specified after -O
option or as the last argument.
-O <dir> specifies the target directory where files should be placed
Reference
Example usage
lftp -u $FTP_USER,$FTP_PWD sftp://$FTP_SERVER:22 <<EOF
mmv dir/to/path /dir/to/renamed/path
EOF

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.

Create and update archive over ssh on local machine

I am trying to find a way to create and update a tar archive of files on a remote system where we don't have write permissions (the remote file system is read only) over ssh. I've figured out that the way to create a archive is,
ssh user#remoteServer "tar cvpjf - /" > backup.tgz
However, I would like to know if there is some way of performing only incremental backups from this point on (of only files that have actually changed?). Any help with this is much appreciated.
You can try using the --listed-incremental option of tar:
http://www.gnu.org/software/tar/manual/html_node/Incremental-Dumps.html
The main problem is that you have no option to pipe the snar file through the stdout because you are already piping backup.tgz so the best option to store it would be to create the file in the /tmp directory where you should have write permissions and then download it at the end of the backup session.
For example:
ssh user#remoteServer "tar --listed-incremental=/tmp/backup-1.snar -cvpjf - /" > backup-1.tgz
scp user#remoteServer:/tmp/backup-1.snar
And in the following session you will use that .snar file to avoid copying the same files:
scp backup-1.snar user#remoteServer:/tmp/backup-1.snar
ssh user#remoteServer "tar --listed-incremental=/tmp/backup-1.snar -cvpjf - /" > backup-2.tgz

Resources