LINUX
- SSH
- INSTALLATION DE ZSH
- POWERSHELL SUR LINUX
- SSH-AGENT
- Probleme d'acces ZABBIX/GLPI/ETC Ce site est inaccessible 192.168.1.0/24 n'autorise pas la connexion.
SSH
- Tunnel SSH:
# {PORT_LOCAL}:{SERVEUR_DESTINATION}:{PORT_DU_SERVEUR_DISTANT} {IP_A_LAQUELLE_JACCEDE} ssh -L 9999:172.16.0.3:80 192.168.1.210
INSTALLATION DE ZSH
- ZSH
- Installer zsh et curl
apt update && apt install zsh curl git - Télécharger OhmyZSH et l'installer
root@adm-front-01:~# sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" Cloning Oh My Zsh... remote: Enumerating objects: 1386, done. remote: Counting objects: 100% (1386/1386), done. remote: Compressing objects: 100% (1332/1332), done. remote: Total 1386 (delta 31), reused 1142 (delta 26), pack-reused 0 Receiving objects: 100% (1386/1386), 3.19 MiB | 1.74 MiB/s, done. Resolving deltas: 100% (31/31), done. From https://github.com/ohmyzsh/ohmyzsh * [new branch] master -> origin/master branch 'master' set up to track 'origin/master'. Already on 'master' /root Looking for an existing zsh config... Using the Oh My Zsh template file and adding it to /root/.zshrc. Time to change your default shell to zsh: Do you want to change your default shell to zsh? [Y/n] Y Changing your shell to /usr/bin/zsh... Shell successfully changed to '/usr/bin/zsh'. __ __ ____ / /_ ____ ___ __ __ ____ _____/ /_ / __ \/ __ \ / __ `__ \/ / / / /_ / / ___/ __ \ / /_/ / / / / / / / / / / /_/ / / /_(__ ) / / / \____/_/ /_/ /_/ /_/ /_/\__, / /___/____/_/ /_/ /____/ ....is now installed! Before you scream Oh My Zsh! look over the `.zshrc` file to select plugins, themes, and options. • Follow us on Twitter: https://twitter.com/ohmyzsh • Join our Discord community: https://discord.gg/ohmyzsh • Get stickers, t-shirts, coffee mugs and more: https://shop.planetargon.com/collections/oh-my-zsh ➜ ~ - Installer p10k
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k #Set ZSH_THEME="powerlevel10k/powerlevel10k" in ~/.zshrc source ~/.zshrc
- Installer zsh et curl
POWERSHELL SUR LINUX
INSTALLATION
apt upgrade && apt full-upgrade && apt install curl apt-transport-https gnupg2 -y
curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-debian-bullseye-prod bullseye main" > /etc/apt/sources.list.d/microsoft.list'
apt update && apt install -y powershell gss-ntlmssp
SE CONNECTER À DISTANCE EN POWERSHELL
- Installation des modules nécessaires en BASH
pwsh -Command 'Install-Module -Name PSWSMan' --> Redémarrer une session - Installation des module nécessaire en POWERSHELL
pwsh Install-Module -Name PowerShellGet Install-Module -Name PSWSMan -force Install-WSMan - Connexion sur un WINDOWS SERVER
PS /root> Enter-PSSession -ComputerName 172.16.0.3 -Authentication Negotiate -Credential megaproduction\administrator PowerShell credential request Enter your credentials. Password for user megaproduction\administrator: ******** [172.16.0.3]: PS C:\Users\Administrator\Documents> hostname ads-front-01
Il faudra au préalable avoir lancé ces commande sur le serveur distant:
Enable-PSRemoting -Force
DÉBUT D'AUTOMATISATION
- Création de la commande à lancer
$creds = Get-Credential -UserName megaproduction\administrator $block = {Get-WindowsFeature | Where { $_.Installed } | Select Name,DisplayName,Description | select -First 4} # Lancement du contenu de la variable $block sur le serveur distant Invoke-Command -ComputerName RemotePC -Authentication Negotiate -Credential $creds -ScriptBlock $block # On peut aussi lancer un script local sur le serveur distant Invoke-Command -ComputerName RemotePC -Authentication Negotiate -Credential $creds -FilePath C:\Scripts\my_script.ps1 - Résultat attendus
PS /root> Invoke-Command -ComputerName 172.16.0.3 -Authentication Negotiate -Credential $creds ` >> -ScriptBlock $block -verbose Name : AD-Domain-Services DisplayName : Active Directory Domain Services Description : Active Directory Domain Services (AD DS) stores information about objects on the network and makes this information available to users and network administrators. AD DS uses domain controllers to give network users access to permitted resources anywhere on the network through a single logon process. PSComputerName : 172.16.0.3 RunspaceId : 553f7cb6-c422-4fa2-a93e-62525616f57a Name : DNS DisplayName : DNS Server Description : Domain Name System (DNS) Server provides name resolution for TCP/IP networks. DNS Server is easier to manage when it is installed on the same server as Active Directory Domain Services. If you select the Active Directory Domain Services role, you can install and configure DNS Server and Active Directory Domain Services to work together. PSComputerName : 172.16.0.3 RunspaceId : 553f7cb6-c422-4fa2-a93e-62525616f57a Name : FileAndStorage-Services DisplayName : File and Storage Services Description : File and Storage Services includes services that are always installed, as well as functionality that you can install to help manage file servers and storage. PSComputerName : 172.16.0.3 RunspaceId : 553f7cb6-c422-4fa2-a93e-62525616f57a Name : File-Services DisplayName : File and iSCSI Services Description : File and iSCSI Services provides technologies that help you manage file servers and storage, reduce disk space utilization, replicate and cache files to branch offices, move or fail over a fil e share to another cluster node, and share files by using the NFS protocol. PSComputerName : 172.16.0.3 RunspaceId : 553f7cb6-c422-4fa2-a93e-62525616f57a
SSH-AGENT
Mise en place du démarrage de ssh-agent automatiquement
ZSH
echo "eval $(ssh-agent -s)" >> ~/.zshrc
echo "ssh-add ~/.ssh/id_rsa" >> ~/.zshrc
source ~/.zshrc
BASH
echo "eval $(ssh-agent -s)" >> ~/.bashrc
echo "ssh-add ~/.ssh/id_rsa" >> ~/.bashrc
source ~/.bashrc