Enhanced Security Measures in Place:   To ensure a safer experience, we’ve implemented additional, temporary security measures for all users.

forcefully logout all GP users from gateways

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements

forcefully logout all GP users from gateways

L1 Bithead

Hi Anyone,

 

I'm trying to logout all GP VPN users forcefully logout from the gateway either doesn't logout users or no errors throwing on command as well

 

>request global-protect-gateway client-logout gateway gp-gateway reason force-logout user * computer *

 

Login & logout time is same before and after execute this commands. Please let me know, have any one tried this way or share the correct commands.


Regards,

Karup

2 accepted solutions

Accepted Solutions

L1 Bithead

Please use the below command to logout all users from the portal but this command could also be working from PAN 9.0.

> request global-protect-portal client-logout portal <value> reason <force-logout> filter-user all-users

 

Below is the command to disconnect all users at once from a Gateway but this feature is only available from the PAN-OS 9.0.2

>request global-protect-gateway client-logout-all gateway <value>

 

Regards,

Karup

View solution in original post

I'm on 8.1, so I used the API to loop through users and log them off.  I came up with this set of commands that I can run from any linux box with curl and xmllint

FW=your_firewall_name
GW=your_gateway_name
# read admin password into environment variable so it is hidden from history file
read -s pass
# get a key to use the api
install -m 0600 /dev/null pa_${FW}.key
RESP=$(curl -kq https://${FW}/api --data-urlencode "type=keygen" --data-urlencode "user=admin" --data-urlencode "password=${pass}")
xmllint --xpath "//key/text()" <(echo $RESP) > pa_${FW}.key
# get connected users, then loop over them to log them off
USERS=$(curl -kq  https://${FW}/api -d "type=op" -d "cmd=<show><global-protect-gateway><current-user><gateway>${GW}</gateway></current-user></global-protect-gateway></show>" -d "key=$(cat pa_${FW}.key)")
for i in $(seq $(xmllint --xpath "count(//username)" <(echo $USERS) )); do 
  U=$(xmllint --xpath "//entry[$i]/username/text()" <(echo $USERS))
  D=$(xmllint --xpath "//entry[$i]/domain/text()" <(echo $USERS))
  C=$(xmllint --xpath "//entry[$i]/computer/text()" <(echo $USERS))
  echo logout: ${C}:${D}:${U}
  curl -kq https://${FW}/api -d "type=op" -d "cmd=<request><global-protect-gateway><client-logout><computer>${C}</computer><domain>${D}</domain><user>${U}</user><gateway>${GW}-N</gateway></client-logout></global-protect-gateway></request>" -d "key=$(cat pa_${FW}.key)"
done

 

View solution in original post

4 REPLIES 4

Community Team Member

Hi @Karup ,

 

As far as I can see only portal users can be logged out all at once.

 

> request global-protect-portal client-logout portal <value> reason force-logout filter-user all-users

 

This seems like a missing feature on the gateway to disconnect all users at once.  You can do it for one user on the CLI or from the UI Network>GlobalProtect>Gateways> <value> >Remote Users

 

You might want to raise a feature request with your local SE.

 

Cheers,

-Kiwi.

 
LIVEcommunity team member, CISSP
Cheers,
Kiwi
Please help out other users and “Accept as Solution” if a post helps solve your problem !

Read more about how and why to accept solutions.

L1 Bithead

Thanks for your comment Kiwi! I'll get this with PA SE.

L1 Bithead

Please use the below command to logout all users from the portal but this command could also be working from PAN 9.0.

> request global-protect-portal client-logout portal <value> reason <force-logout> filter-user all-users

 

Below is the command to disconnect all users at once from a Gateway but this feature is only available from the PAN-OS 9.0.2

>request global-protect-gateway client-logout-all gateway <value>

 

Regards,

Karup

I'm on 8.1, so I used the API to loop through users and log them off.  I came up with this set of commands that I can run from any linux box with curl and xmllint

FW=your_firewall_name
GW=your_gateway_name
# read admin password into environment variable so it is hidden from history file
read -s pass
# get a key to use the api
install -m 0600 /dev/null pa_${FW}.key
RESP=$(curl -kq https://${FW}/api --data-urlencode "type=keygen" --data-urlencode "user=admin" --data-urlencode "password=${pass}")
xmllint --xpath "//key/text()" <(echo $RESP) > pa_${FW}.key
# get connected users, then loop over them to log them off
USERS=$(curl -kq  https://${FW}/api -d "type=op" -d "cmd=<show><global-protect-gateway><current-user><gateway>${GW}</gateway></current-user></global-protect-gateway></show>" -d "key=$(cat pa_${FW}.key)")
for i in $(seq $(xmllint --xpath "count(//username)" <(echo $USERS) )); do 
  U=$(xmllint --xpath "//entry[$i]/username/text()" <(echo $USERS))
  D=$(xmllint --xpath "//entry[$i]/domain/text()" <(echo $USERS))
  C=$(xmllint --xpath "//entry[$i]/computer/text()" <(echo $USERS))
  echo logout: ${C}:${D}:${U}
  curl -kq https://${FW}/api -d "type=op" -d "cmd=<request><global-protect-gateway><client-logout><computer>${C}</computer><domain>${D}</domain><user>${U}</user><gateway>${GW}-N</gateway></client-logout></global-protect-gateway></request>" -d "key=$(cat pa_${FW}.key)"
done

 

  • 2 accepted solutions
  • 9038 Views
  • 4 replies
  • 0 Likes
Like what you see?

Show your appreciation!

Click Like if a post is helpful to you or if you just want to show your support.

Click Accept as Solution to acknowledge that the answer to your question has been provided.

The button appears next to the replies on topics you’ve started. The member who gave the solution and all future visitors to this topic will appreciate it!

These simple actions take just seconds of your time, but go a long way in showing appreciation for community members and the LIVEcommunity as a whole!

The LIVEcommunity thanks you for your participation!