Showing posts with label SSH. Show all posts
Showing posts with label SSH. Show all posts

Ansible Remote Shell Examples

To execute remote commands or get access to a remote server using ansible, you can do:

source =prdeu4spl002 
destination = prdus1ans105 
auth = ssh-keys already installed (not part of the example)
command1 = pwd
command2 = ls -lah
command3 = /usr/local/sbin/schedule-downtime -s "now" -d 1 -r "Test Downtime"

Example


[spluser@prdeu4spl002 ansible]$
[spluser@prdeu4spl002 ansible]$
[spluser@prdeu4spl002 ansible]$ ansible all -i ,prdus1ans105 -b -m shell -a 'pwd'
prdus1ans105 | CHANGED | rc=0 >>
/home/spluser
[spluser@prdeu4spl002 ansible]$
[spluser@prdeu4spl002 ansible]$ ansible all -i ,prdus1ans105 -b -m shell -a 'ls -lah'
prdus1ans105 | CHANGED | rc=0 >>
total 16K
drwx------. 5 spluser spluser 130 Jul 25 2024 .
drwxr-xr-x. 12 root root 183 May 8 15:20 ..
drwx------ 3 spluser spluser 17 Jun 25 2024 .ansible
-rw------- 1 spluser spluser 182 Jun 4 12:55 .bash_history
-rw-r--r--. 1 spluser spluser 18 Jun 20 2022 .bash_logout
-rw-r--r--. 1 spluser spluser 141 Jun 20 2022 .bash_profile
-rw-r--r--. 1 spluser spluser 376 Jun 20 2022 .bashrc
drwxr-x--- 5 spluser spluser 39 Jun 25 2024 .puppetlabs
drwx------. 2 spluser spluser 29 Jun 25 2024 .ssh
[spluser@prdeu4spl002 ansible]$
[spluser@prdeu4spl002 ansible]$
[spluser@prdeu4spl002 ansible]$ ansible all -i ,prdus1ans105 -b -m shell -a '/usr/local/sbin/schedule-downtime -s "now" -d 1 -r "Test Downtime"'
prdus1ans105 | CHANGED | rc=0 >>

Now scheduling a downtime from 14:59:02 until 15:00:02 for prdus1ans105 in Mon01 and nIcinga because of "Test Downtime" on behalf of user ROOT.

contacting the Mon01 satellite REST API...
OK

contacting the nIcinga REST API...
OK
[spluser@prdeu4spl002 ansible]$
[spluser@prdeu4spl002 ansible]$



Zenmap show SSHv2 algorithms/cipher suite

Discover the used SSHv2 algorithms/cipher suite using nmap or zenmap can be done using the follwing nse-script and steps:

URL: https://nmap.org/nsedoc/scripts/ssh2-enum-algos.html
Download: https://svn.nmap.org/nmap/scripts/ssh2-enum-algos.nse

Howto Use Guide

  1. Download NSE-Script
  2. Save nse-script-file into your ...\NMap\Scripts\ folder
    NMap\Scripts\ folder screenshot
  3.  Run nmap or zenmap and the command: nmap --script ssh2-enum-algos *your-target*
    Zenmap screenshot

Example Output

Starting Nmap 7.80 ( https://nmap.org ) at 2021-07-03 21:18 Mitteleuropäische Zeit
Nmap scan report for 10.140.68.24
Host is up (0.016s latency).
Not shown: 997 filtered ports
PORT STATE SERVICE
22/tcp open ssh
| ssh2-enum-algos:
| kex_algorithms: (10)
| curve25519-sha256
| curve25519-sha256@libssh.org
| ecdh-sha2-nistp256
| ecdh-sha2-nistp384
| ecdh-sha2-nistp521
| diffie-hellman-group-exchange-sha256
| diffie-hellman-group16-sha512
| diffie-hellman-group18-sha512
| diffie-hellman-group14-sha256
| diffie-hellman-group14-sha1
| server_host_key_algorithms: (5)
| rsa-sha2-512
| rsa-sha2-256
| ssh-rsa
| ecdsa-sha2-nistp256
| ssh-ed25519
| encryption_algorithms: (6)
| chacha20-poly1305@openssh.com
| aes128-ctr
| aes192-ctr
| aes256-ctr
| aes128-gcm@openssh.com
| aes256-gcm@openssh.com
| mac_algorithms: (10)
| umac-64-etm@openssh.com
| umac-128-etm@openssh.com
| hmac-sha2-256-etm@openssh.com
| hmac-sha2-512-etm@openssh.com
| hmac-sha1-etm@openssh.com
| umac-64@openssh.com
| umac-128@openssh.com
| hmac-sha2-256
| hmac-sha2-512
| hmac-sha1
| compression_algorithms: (2)
| none
|_ zlib@openssh.com 

Author: Kris Katterjohn
License:
Same as Nmap--See https://nmap.org/book/man-legal.html

Monitor UniFi WLAN Access Point with PRTG with SNMPv3 Auth+Encrypted

This is a tiny guide howto monitor your UniFi wireless accesspoint, in this case a Unifi U7 pro with SNMPv3 with AES-Encryption and SHA-Auth...