WebSphere MQ Viewing Channels in WMQ Explorer - ibm-mq

We need to execute SET AUTHREC PROFILE($cname) OBJTYPE(CHANNEL) GROUP('mq-user') AUTHADD(...) so that the channels show up WMQ Explorer, it that correct? Current the access is prevented.

Yes. With the AUTHREC profiles defined in this and previous questions you have authorized the user to connect to the QMgr, put requests to the command queue and receive replies on a model queue. The command server needs to know what operations on other objects the group is authorized for. As an example, it won't display or let members of the group control channels until you authorize them.
A quick way to see what objects need to be authorized is the Role Based Authorities Wizard in WMQ Explorer. Right-click on the QMgr, select Object Authorities, then Add Role Based Authorities like so:
Next, select Group and put in the group name:
The wizard outputs setmqaut commands which you can issue from the command line as mqm. There are equivalent AUTHREC commands for these. Rather than convert them manually, I'd recommend running the setmqaut versions, then capturing the rule using the dmpmqcfg command.
The actual commands created in the wizard using the settings above are:
setmqaut -m QM75_1 -t qmgr -g mq-user +connect +inq +dsp
setmqaut -m QM75_1 -n "**" -t q -g mq-user +dsp
setmqaut -m QM75_1 -n "**" -t topic -g mq-user +dsp
setmqaut -m QM75_1 -n "**" -t channel -g mq-user +dsp
setmqaut -m QM75_1 -n "**" -t process -g mq-user +dsp
setmqaut -m QM75_1 -n "**" -t namelist -g mq-user +dsp
setmqaut -m QM75_1 -n "**" -t authinfo -g mq-user +dsp
setmqaut -m QM75_1 -n "**" -t clntconn -g mq-user +dsp
setmqaut -m QM75_1 -n "**" -t listener -g mq-user +dsp
setmqaut -m QM75_1 -n "**" -t service -g mq-user +dsp
setmqaut -m QM75_1 -n "**" -t comminfo -g mq-user +dsp
setmqaut -m QM75_1 -n SYSTEM.MQEXPLORER.REPLY.MODEL -t q -g mq-user +dsp +inq +get
setmqaut -m QM75_1 -n SYSTEM.ADMIN.COMMAND.QUEUE -t q -g mq-user +dsp +inq +put

Related

Subscribe and Publish in BASH like a receive Buffer

I want to buffer all messages of a subscription during processing publish messages.
The reason is a firmware update over MQTT. I want to send data with crc and the microcontroller have to verify the content and need to answer with new address pointer.
For now, i got it working without any interaction from the microcontroller. If size doesn't fit, or mc is not online, my bash script sends all the data of the binary file into the nirvana.
If I publish a message and subscribe directly after the publish, it is possible to lose an answer very easily.
But I'm not so experienced with bash and I need some suggestions how to do this...
This is what I have:
mosquitto_pub -h $MQTT_SERVER -t "spiffs/${client_name}/file_info" -m "$binary_file" -p 8883 -i "fw_server" --cafile server-cert.pem -d --insecure -u $MQTT_USER -P $MQTT_PW
mosquitto_sub -h $MQTT_SERVER -p 8883 -t "+/${client_name}/#" -i "fw_server" --cafile server-cert.pem -d --insecure -u $MQTT_USER -P $MQTT_PW | while read -r payload
do
fp_jq_rspCode=".upload.fp" # file pointer
address=$(echo $payload | jq -r $fp_jq_rspCode)
echo "${payload}" | jq -c '.[]'
echo "address pointer:$address"
c=${address}
addr=$(printf '%08x' "$c")
content=$(xxd -p -c $payload_size -l $payload_size -seek $c $binary_file)
length=`expr length "$content"`
len=$(printf '%04x' "$length")
crc32=$(echo -n "$content" | gzip -c | tail -c8 | hexdump -n4 -e '"%u"')
crc32=$(printf '%08x' "$crc32")
echo "$addr $len $content $crc32"
message=$(printf '%08x%04x%s%s' "$c" "$length" "$content" "$crc32")
mosq=$(mosquitto_pub -h $MQTT_SERVER -t "spiffs/${client_name}/upload" -m "$message" -p 8883 -i "fw_server" --cafile server-cert.pem -d --insecure -u $MQTT_USER -P $MQTT_PW)
done

ERROR => ERROR => SMTP-AUTH: Authentication to smtp.gmail.com:587 failed

I am trying to send an email using below command but i am getting below error:
Command executed:
/usr/bin/sendemail -v -f "mymail#gmail.com" -u "Re : Alerts Script" \
-t "$EMAILS" -s "smtp.gmail.com:587" -o tls=yes -xu "my#gmail.com" \
-xp "Password" -m "$Msg"
I tried with port 25, Still same error getting.
If i use 465 port getting below error
ERROR => smtp.gmail.com:465 returned a zero byte response to our query.
/usr/bin/sendemail -v -f "mymail#gmail.com" -u "Re : Alerts Script" \
-t "$EMAILS" -s "smtp.gmail.com:587" -o tls=yes -xu "my#gmail.com" \
-xp "Password" -m "$Msg"
Email should go for given email id's
I had faced the same issue and could resolve it. You can use the tls auto, 587 port command. Able to successfully send an email using Gmail SMTP.
/usr/bin/sendemail -f "mymail#gmail.com" -u "Re : Alerts Script" -t "$EMAILS" -s "smtp.gmail.com:587" -o tls=auto -xu "mymail#gmail.com" -xp "Password" -m "$Msg"
Also, you have to apply couple of settings in Gmail.
Enable IMAP
Allow less secure app
Review suspicious activity and mark 'That's me' to allow communication.
Also in windows you need to add sendEmail to your firewall.
To resolve this error for me in Windows (should work in any OS), I had to go into my Gmail account/Security/App Passwords on the web and generate a 16-digit password for App:"Mail" and Device:"Windows Computer" (you can create a custom device too) to give special access to the device where I was running SendEmail.
Per Google: "App passwords let you sign in to your Google Account from apps on devices that don't support 2-Step Verification."
Then I used that 16-digit password in SendEmail instead of my gmail password and it finally went through.
c:\sendemail\sendemail -o tls=yes -t recipient#email.*** -m Title HELLO -f [myaccount]#gmail.com -s smtp.gmail.com:587 -xu [myaccount]#gmail.com -xp **************** -l C:\sendemail\logfile.txt

Weird output observed on executing ssh commands remotely over ProxyCommand

Team, I have two steps to perform:
SCP a shell script file to remote ubuntu linux machine
Execute this uploaded file on remote ubuntu linux machine over SSH session using PROXYCommand because I have bastion server in front.
Code:
scp -i /home/dtlu/.ssh/key.key -o "ProxyCommand ssh -i /home/dtlu/.ssh/key.key lab#api.dev.test.com -W %h:%p" /home/dtlu/backup/test.sh lab#$k8s_node_ip:/tmp/
ssh -o StrictHostKeyChecking=no -i /home/dtlu/.ssh/key.key -o 'ProxyCommand ssh -i /home/dtlu/.ssh/key.key -W %h:%p lab#api.dev.test.com' lab#$k8s_node_ip "uname -a; date;echo "Dummy123!" | sudo -S bash -c 'echo 127.0.1.1 \`hostname\` >> /etc/hosts'; cd /tmp; pwd; systemctl status cachefilesd | grep Active; ls -ltr /tmp/test.sh; echo "Dummy123!" | sudo -Sv && bash -s < test.sh"
Both calls above are working fine. I am able to upload test.sh and also its running but what is bothering me is during the process am observe weird output being thrown out.
output:
/tmp. <<< expected
[sudo] password for lab: Showing one
Sent message type=method_call sender=n/a destination=org.freedesktop.DBus object=/org/freedesktop/DBus interface=org.freedesktop.DBus member=Hello cookie=1 reply_cookie=0 error=n/a
Root directory /run/log/journal added.
Considering /run/log/journal/df22e14b1f83428292fe17f518feaebb.
Directory /run/log/journal/df22e14b1f83428292fe17f518feaebb added.
File /run/log/journal/df22e14b1f83428292fe17f518feaebb/system.journal added.
So, I don't want /run/log/hournal and other lines which don't correspond to my command in sh.
Consider adding -q to the scp and ssh commands to reduce the output they might produce. You can also redirect stderr and stdout to /dev/null as appropriate.
For example:
{
scp -q -i /home/dtlu/.ssh/key.key -o "ProxyCommand ssh -i /home/dtlu/.ssh/key.key lab#api.dev.test.com -W %h:%p" /home/dtlu/backup/test.sh lab#$k8s_node_ip:/tmp/
ssh -q -o StrictHostKeyChecking=no -i /home/dtlu/.ssh/key.key -o 'ProxyCommand ssh -i /home/dtlu/.ssh/key.key -W %h:%p lab#api.dev.test.com' lab#$k8s_node_ip "uname -a; date;echo "Dummy123!" | sudo -S bash -c 'echo 127.0.1.1 \`hostname\` >> /etc/hosts'; cd /tmp; pwd; systemctl status cachefilesd | grep Active; ls -ltr /tmp/test.sh; echo "Dummy123!" | sudo -Sv && bash -s < test.sh"
} >&/dev/null

golang ssh quiet mode

In golang ssh(golang.org/x/crypto/ssh) package how to force the ssh command to use quiet mode i.e. simulate 'ssh -q'
I looked at Config and ClientConfig structures as well as tried searching for 'quiet' or options in the documentation(https://godoc.org/golang.org/x/crypto/ssh) but can't find anything.
Credits: Thanks to #JimB and #Kenster for nailing this.
Quiet mode is not required for (golang.org/x/crypto/ssh). Extra messages that you would usually see when using a ssh CLI won't appear when using (golang.org/x/crypto/ssh). Here is an example of extra messages:
sshpass -ppassword ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no 10.10.10.10 'ls | wc -l'
Warning: Permanently added '10.10.10.10' (ECDSA) to the list of known hosts.
19
sshpass -ppassword ssh -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no 10.10.10.10 'ls | wc -l'
19

Merge two Batch Files into one

i have written a small script that is taking infos from an console application and sending it via email to me. I have used Quiet to let the programm run in the background.
start.bat
Quiet script.bat
script.bat
info.exe > "data.txt"
sendEmail -o tls=yes -f myemail#gmail.com -t myemail#gmail.com -s smtp.gmail.com:587 -xu myemail#gmail.com -xp mypasswd -u "XXX" -m "XXX" -a "data.txt"
del "data.txt"
if i run it like this it works fine but when i try to make one file of it like:
script.bat
Quiet script.bat
info.exe > "data.txt"
sendEmail -o tls=yes -f myemail#gmail.com -t myemail#gmail.com -s smtp.gmail.com:587 -xu myemail#gmail.com -xp mypasswd -u "XXX" -m "XXX" -a data.txt"
del "data.txt"
It sends infinte amount of emails. When i make it like this it works but not like i want it to.
script.bat
Quiet script.bat
pause
info.exe > "data.txt"
sendEmail -o tls=yes -f myemail#gmail.com -t myemail#gmail.com -s smtp.gmail.com:587 -xu myemail#gmail.com -xp mypasswd -u "XXX" -m "XXX" -a data.txt"
pause
del "data.txt"
The reason for the infinite mails is that you call the batch file inside the batch file, which causes an infinite loop of running the batch.
The problem is with the logic of what that you are expecting to happen,
you want to click the batch file and expect that it will run by Quiet before it runs in shell.
If you just want to run it in background, you can easily achieve it by running it as "System"(with a service/schedule task and etc.), otherwise I think that you can't resolve this issue(you expect that another executable will run the current batch you are clicking - the first batch will always open a window).
Because you are clicking to start the program, the shortcut can have the launching command in it, changed in the properties.
"c:\folder\Quiet.exe" "c:\batch\folder\script.bat"
and then there is just the one batch file.
UPDATE
Not sure I understood everything.
One way would be in script.bat
Probably echo are needed in front of each command. if it doesn't work, try in one line
#echo off
(
echo info.exe > "data.txt"
echo sendEmail -o tls=yes -f myemail#gmail.com -t myemail#gmail.com -s smtp.gmail.com:587 -xu myemail#gmail.com -xp mypasswd -u "XXX" -m "XXX" -a "data.txt"
echo del "data.txt"
) > output.txt 2>&1 | Quiet.exe
Or in one liner
#echo off
(
echo info.exe > "data.txt" &&^
echo sendEmail -o tls=yes -f myemail#gmail.com -t myemail#gmail.com -s smtp.gmail.com:587 -xu myemail#gmail.com -xp mypasswd -u "XXX" -m "XXX" -a "data.txt" &&^
echo del "data.txt" &&^
) > output.txt 2>&1 | Quiet.exe
In this way, start.bat is not necessary.
Which is equivalent to this:
Quiet.exe info.exe > "data.txt" && sendEmail -o tls=yes -f myemail#gmail.com -t myemail#gmail.com -s smtp.gmail.com:587 -xu myemail#gmail.com -xp mypasswd -u "XXX" -m "XXX" -a "data.txt" && del "data.txt"
EDIT:
#echo off
Quiet start cmd /c "info.exe > 'data.txt' && sendEmail -o tls=yes -f myemail#gmail.com -t myemail#gmail.com -s smtp.gmail.com:587 -xu myemail#gmail.com -xp mypasswd -u "XXX" -m "XXX" -a 'data.txt' && del 'data.txt'"
Pause
In the last example, you have to deal with double quotes, probably not necessary.

Resources