sendemail unable to connect to stunnel on IP 127.0.0.1 (Port 259) - email

I recently setup a new Windows 10 computer. On it I transfered scripts I am using elseware. The script involves sendemail.exe sending out an email using stunnel to gmail.
The script is as follows:
c:\Program Files (x86)\sendEmail>sendEmail.exe -l c:\temp\sendemail.log -t email#gmail.com -u "Email Subject" -m "Email Message" -s 127.0.0.1:6259 -f senderemail#gmail.com -xu senderemail -xp 123456789012345 -o tls=auto
The above commands fails with the following error: '''Aug 07 15:45:15 dell-pms sendEmail.exe[5196]: ERROR => Connection attempt to 127.0.0.1:6259 failed: IO::Socket::INET: connect: Unknown error'''
Replacing 127.0.0.1 with localhost fails.
Repeating the command but replacing the IP address (127.0.0.1) with the computer's IP address 192.168.16.76 works.
The hosts file is the default (everything remarked).
Any suggestion how to diagnose.

Related

use existing SSH_AUTH_SOCK to execute commands on remote server

I connect to my work server (workserver1.com) from my local PC (localhost) using SSH and execute a bunch of commands on workserver1.
Below are the commands I execute using SSH
1) run script on server collect production data and put it in a txt
ssh -A workserver1.com 'python3 /usr/local/collect_data_online.py 2>&1 | tee /home/myname/out.txt'
$ please input your dynamic token: <manually input credential token generated every 15s>
2) filter lines I need and put in a dat file
ssh -A workserver1.com "grep 'my-keyword-cron' out.txt | grep -oP '({.*})' | tee workserver2.dat"
$ please input your dynamic token: <manually input credential token again>
3) send data collected in 2) and send to workserver2 which could only access through workserver1**
ssh -A workserver1.com 'curl workserver2.com --data-binary "#workserver2.dat" --compressed' "
$ please input your dynamic token: <manually input credential token 3rd time>
In each steps above , I actually created 3 completed different socket with workserver1.com. I got this info from running command below on remote server
$ ssh -A workserver1.com 'printenv | grep SSH'
SSH_CLIENT=10.126.192.xxx 58276 22
SSH_SESSION_ID=787878787878787878
SSH_TTY=/dev/pts/0
SSH_AUTH_SOCK=/tmp/ssh-XXXXKuJLEX/agent.29291
SSH_AUTH_CERT_SERIAL=666666666
SSH_AUTH_CERT_KEY=myname
# SSH_CONNECTION changes each time I make a SSH request to workserver1.com. so I need repeatedly input dynamic token manually
SSH_CONNECTION=10.126.192.xxx 58276 10.218.35.yyy 22
On my localhost I can also see SSH sock which used for the SSH connection
$ SSH_AUTH_SOCK=/tmp/ssh-localhost/agent.12345
My question is , is there a way to using single existing socket to avoid making multiple SSH connections and just input the dynamic token once. I hope I could use existing sock to interactively type commands to this SSH server and collect outpu/data as I want , just like on my localhost
What's in my mind is
1) socat can I run some command on localhost like
socat UNIX-CONNECT:$SSH_AUTH_SOCK,exec:'commands I want to execute' - ==> possible to get an interactive client&server shell?
2) is there any ssh option I could use ?
I am new to socat and not familiar with ssh except some commonly used commands
Thank you for your help in advance
The solution is open the first connection with '-M'
First use ControlMaster and ControlPath in ~/.ssh/config as below:
host *
ControlMaster auto
ControlPath ~/.ssh/ssh_mux_%h_%p_%r
And when connect toremote host the very first time, add '-M'
ssh -M $remotehost
Then in follow ssh connection with the same host you could just use
ssh $remotehost

SNMPD to configure as Proxy agent

Am configuring SNMPD to acts as proxy agent between SNMP manager(snmpb browser) and Network devices in centOS by referring https://net-snmp.sourceforge.io/wiki/index.php/Snmpd_proxy. After adding the <proxy -Cn testname -v 3 -u testUser -a MD5 -A "PasswordA" -x DES -X "PasswordX" -l authPriv ipaddress .1.3> in snmpd.config file, getting the below mentioned error on that line.
Error: failed to parse proxy args.
Kindly help me to resolve this.

SMTP Server Mail Alerts using TLS and authentication issue

I am a bit new in using SMTP server Alert configurations on AIX 7.1 OS . I am currently using below syntax which is running fine :
mail -s "Subject" "abc#test.com" < /path/to/my/input.txt
but we are now migrating our SMTP server with authentication and TLS enable but I am unable to do so. please guide me what am I doing wrong:
echo "This is the message body and contains the message" | mailx -v -s "This is the subject" -S smtp=smtp://newsmptp.test.com:25 -S smtp-use-starttls -S smtp-auth=login -S smtp-auth-user="temp" -S smtp-auth-password="Abc#123" -S ssl-verify=ignore "abc#test.com
The error I get is:
mailx: Not a recognized flag: S

SSMTP fails after migrating to Buster

SSMTP was working for years now on my RPi - latest on stretch.
Now I migrated to buster - and after this step it now fails.
$ cat /etc/ssmtp/ssmtp.conf
root=user#mydomain.com
mailhub=smtp.gmail.com:587
hostname=localhost
UseSTARTTLS=YES
AuthUser=user#gmail.com
AuthPass=very_secret
FromLineOverride=YES
$ echo "MailBody"|mail --debug-level=3 -s "My Subject" mailaddress#domain.com
mail: sendmail binary: /usr/sbin/sendmail
mail: source=system, name=user, passwd=x, uid=1001, gid=1000, gecos=user,,,, dir=/home/user, shell=/bin/bash, mailbox=/var/mail/user, quota=0, change_uid=1
mail: source=system, name=user, passwd=x, uid=1001, gid=1000, gecos=user,,,, dir=/home/user, shell=/bin/bash, mailbox=/var/mail/user, quota=0, change_uid=1
mail: mu_mailer_send_message(): using From: user#localhost
mail: Sending headers...
mail: Sending body...
mail: /usr/sbin/sendmail exited with: 1
mail: progmailer error: Process exited with a non-zero status
mail: cannot send message: Process exited with a non-zero status
mail: source=system, name=user, passwd=x, uid=1001, gid=1000, gecos=user,,,, dir=/home/user, shell=/bin/bash, mailbox=/var/mail/user, quota=0, change_uid=1
$ echo $?
36
I have a lot of shell-scripts sending mails with commands like:
echo "MailBody"|mail -s "My Subject" emailaddress#domain.com
=> so if SSMTP is no longer supported, I would neeed a solution following that syntax ...
thanks for any help!
I fixed this by switching away from ssmtp (which some sources say being unmaintained) to msmtp (https://wiki.debian.org/msmtp).
This could or could not apply to you, try to check the error code by sending an email directly via /usr/sbin/ssmtp -v ...., I had exit 36 (echo $? to get the code).
If you are in a similar situation and want to give msmtp a try, these the steps I followed:
Install:
$ sudo apt remove ssmtp
$ sudo apt install msmtp msmtp-mta
Configure (I'm not configuring GMail, I use Dreamhost email service, so your details might be different):
$ cat /etc/msmtprc
# Set default values for all following accounts.
defaults
auth on
tls on
tls_starttls off
tls_trust_file /etc/ssl/certs/ca-certificates.crt
logfile /tmp/msmtp.log
# Raspberry Pi
account rasp
host smtp.dreamhost.com
port 465
from raspberry#<REDACTED>
user raspberry#<REDACTED>
password <PLAINTEXTPASSWORD>
# default account
account default : rasp
For comparison, this was my /etc/ssmtp.conf file:
root=postmaster
mailhub=smtp.dreamhost.com:465
AuthUser=raspberry#<REDACTED>
AuthPass=<REDACTED>
UseTLS=YES
UseSTARTTLS=YES
TLS_CA-File=/etc/ssl/certs/ca-certificates.crt
hostname=<REDACTED>.org
FromLineOverride=NO
Set msmtp as default MTA. I've added the last line to my mail.rc file:
$ cat /etc/mail.rc
set ask askcc append dot save crt
ignore Received Message-Id Resent-Message-Id Status Mail-From Return-Path Via Delivered-To
set mta=/usr/bin/msmtp
[NOTE]: There is also an issue with msmtp in that it's not populating automatically the "From:" header in the message so emails get rejected, to fix it, when calling mail make sure to do it manually:
echo TEST | mail -a "From: raspberry#<REDACTED>" --debug-level 10 -s '[rasp] server' <REDACTED>#gmail.com
This makes email sending work again from my Raspberry Pi on Debian buster/sid.

How to get the IP address used by a Parallels VM from the host?

Parallels has a command line API which is documented here
>prlctl list
UUID STATUS IP_ADDR NAME
{ca50aac6-caa6-47a6-9bfe-e38f6261cb8d} running - win7
Still, even with this the IP_ADDR reported is always empty, even if the machine is running as has an internet connection.
How can I find the IP of the machine from the guest? I need a way to connect to the guest, by using a domain name or an IP.
If it's a Windows VM, you can get the IP with the following command from the host:
prlctl exec "VM Name" ipconfig | grep "IPv4" | grep -o '\d\{1,3\}\.\d\{1,3\}\.\d\{1,3\}\.\d\{1,3\}'
For a *nix VM:
prlctl exec "VM Name" ifconfig eth1 | grep "inet " | grep -o 'addr:\d\{1,3\}\.\d\{1,3\}\.\d\{1,3\}\.\d\{1,3\}' | grep -o '\d\{1,3\}\.\d\{1,3\}\.\d\{1,3\}\.\d\{1,3\}'
if you want to access the machine using SSH there is a built in command that can help with this.
prlctl enter <VM_ID|VM_NAME>
This will open a prompt as root to the VM
if you want the IP for any other reason there is another way to get it
prlctl exec <VM_ID|VM_NAME> ifconfig
The exec command from prlctl will execute the ifconfig command on the host linux machine (if using windows do ipconfig instead of ifconfig)
All the output of the ifconfig will be printed on your terminal and the ip will be clearly visible in the output
I stumbled upon this today and found it questionable that the list command shows an IP_ADDR but never the IP. I checked the most recent docs for the prlctl command and its states:
-f, --full
Shows the real IP address(es) for running virtual machines.
Providing this flag displays the IP addresses for me
prlctl list -f