Thursday, March 22, 2018

Sometimes you just have to send an email from a server you are currently working on, or you just need to test whether your email server is working, either way, you can always count on netcat to to the job for you. Below command will connect to the mail server you want, on port 25, and send email from there. Please take note, that this command is used in CentOS 7 server, using nmap-ncat-6.40-7.el7 package.

Connect to the mail.foo.bar on port 25

$ nc mail.foo.bar 25220 mail.foo.bar ESMTP Postfix

Once connected, say hello to the email server

$ nc my.email.server 25
220 mail.foo.bar ESMTP Postfix

HELO foo.bar

250 mail.foo.bar

Specify a return address, just in case the email bounced. This is an SMTP protocol requirement.

Put in you message (any message will do, but below is just how normal email usually formatted). Once you are done typing in your message, put dot (.) as a signal you are done with the DATA, and server will reply with your queue number.

Press 'w' to write the changes to disk, and answer 'Y' for confirmation

Command (? for help): wFinal checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTINGPARTITIONS!!Do you want to proceed? (Y/N): YOK; writing new GUID partition table (GPT) to /dev/sda.Warning: The kernel is still using the old partition table.The new table will be used at the next reboot.The operation has completed successfully.

Reinstall grub, so that it will be located in the first partition of the hardisk

Tuesday, January 9, 2018

In order to use rsync with different ssh post, you can use -e flag, and supply ssh command with port option. For example, I want to transfer a file called /root/book.txt from a server called project.local with sshd running on port 55522 to local partition /mnt, I can use this command: