Copy file to VCSA with SCP

Well, in recent weeks we have often talked about how to heal vCenters from the log4j vulnerability.
I guess the first thing we all thought was “What a show VMware support released scripts to run to solve the problem …” and then every one to use WinSCP or similar tools/commands to copy the file …. but many will have found it impossible to copy files using the Root user …. but how SSH works but the SCP command does not work!
Well, the problem comes from the shell associated with the Root user. It is not the classic BASH but the APPLIANCESH.
Then we proceed as follows:

  • Let’s connect in SSH to the vCenter Virtual Appliance
  • We access the Bash SHELL with the command SHELL
  • We enable BASH as the default shell for the root user
  • We run our SCP
  • We re-enable APPLIANCESH for the root user

Copy file to VCSA with SCP

Connessione SSH nodi del cluster AKS (Azure Kubernetes Services)

###Attenzione per eseguire queste operazione dovete aver già dimestichezza con i comandi KUBECTL###

Per prima cosa devo generare la mia coppia di chiavi (Pubblica e Privata).
Utilizzando il mio Windows System Linux (WLS) con Ubuntu genero le chiavi:

ssh-keygen -m PEM -t rsa -b 4096 -C “azureuser”

Dove azureuser è l’utente standard presente sui nodi AKS, e quindi mi server come promemoria.

Adesso ho la coppia di chiavi nella mia directory /home/localadmin/.ssh/, devo scaricarli sul pc le chiavi create

I prossimi passaggi sono quelli di caricare la chiave sul pubblica sul nodo/i a cui voglio collegarmi e utilizzare la mia chiave privata per la connessione ssh utilizzando un container ponte.

Bene adesso  mi devo collegare via Powershell alla  tenant e alla subscription dove è deployato il mio cluster AKS

Connect-AzAccount -Tenant  <ID del Tenant>

az account set –subscription “<Nome della subscription>

$CLUSTER_RESOURCE_GROUP=$(az aks show –resource-group <resource group del AKS> –name <nome dell’AKS> –query nodeResourceGroup -o tsv)
az vm list –resource-group $CLUSTER_RESOURCE_GROUP -o table

Verrà visualizzato l’elenco delle su cui caricare la chiave pubblica.

az vm user update –resource-group $CLUSTER_RESOURCE_GROUP –name <nome del nodo> –username azureuser –ssh-key-value C:tempQTYK8id_rsa.pub

il valore –ssh-key-value è dove abbiamo posizionato localmente la chiave pubblica da caricare sul nodo

Installo il container ponte 

kubectl run –generator=run-pod/v1 -it –rm aks-ssh –image=debian

Mi troverò già dentro al container ponte, a questo punto aprire una nuova powershell, effettuare la procedura di logon (Az Connect ecc..)
Copio la chiave privata sul container ponte (che si chiamerà aks-ssh)

kubectl cp .id_rsa aks-ssh:/root/id_rsa 

Una volta copiata la chiave possiamo tornare alla sessione di powershell in cui siamo già loggati al container aks-ssh
Modificare i permessi al file id_rsa

chmod 06000 /root/id_rsa 

Installare il client SSH nel container.

apt-get update && apt-get install openssh-client -y

Possiamo finalmente loggarci al nostro host AKS per fare le attività richieste (di solito troubleshooting)

ssh -i /root/id_rsa azureuser@<ip del nodo>


Alcune considerazioni:
– Se usciamo dal container ponte AKS-SSH per rientrarci

 kubectl exec -it aks-ssh bash

Se vogliamo vedere se il nostro pod AKS-SSH è presente

kubectl get pod

– L’indirizzo IP del nodo lo posso recuperare dal portale azure

Connessione SSH nodi del cluster AKS (Azure Kubernetes Services)