Outils pour utilisateurs

Outils du site


blog

Notes clefs SSH

Création de la paire de clefs

Création de la paire de clefs par script
if [ ! -e ~/.ssh/id_rsa ]
then
   ssh-keygen -q -N "" < /dev/zero
fi
SSH Générer une clef publique à partir d'une clef privée

Create Public Key from Private

ssh-keygen -y -f ~/.ssh/id_rsa > ~/.ssh/id_rsa.pub
Emprunte (Fingerprint) de la clef SSH
ssh-keygen -lf ~/.ssh/id_rsa.pub
ssh-keygen -E md5 -lf ~/.ssh/id_rsa.pub

Ou

ssh-add ~/.ssh/id_rsa_jbl2
ssh-add -l
ssh-add -L | ssh-keygen -E md5 -lf -

Pour une clef pem générée via AWS (à partir de la clef privée)

openssl pkcs8 -in /home/jibe/.ssh/id_rsa_jbl2 -nocrypt -topk8 -outform DER | openssl sha1 -c

Pb

Pb userauth_pubkey: key type ssh-dss not in PubkeyAcceptedKeyTypes

Voir

/var/log/auth.log

Jan 23 22:40:37 server1 sshd[26567]: userauth_pubkey: key type ssh-dss not in PubkeyAcceptedKeyTypes [preauth]

/etc/ssh/sshd_config

PubkeyAcceptedKeyTypes=+ssh-dss
ssh-keygen -t ecdsa
#ssh-keygen -t ecdsa -b 521
Err no mutual signature algorithm
$ ssh -v old-rhel5
...
debug1: send_pubkey_test: no mutual signature algorithm
...
Solution (contournement)

PubkeyAcceptedKeyTypes +ssh-rsa

~/.ssh/config

Host old-rhel5                                                                                                                                                                                                
  Hostname 192.168.1.20                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           
  KexAlgorithms +diffie-hellman-group1-sha1,diffie-hellman-group14-sha1                                                                                                                                          
  HostKeyAlgorithms +ssh-rsa                                                                                                                                                                                     
  PubkeyAcceptedKeyTypes +ssh-rsa                                                                                                                                                                                
2025/03/24 15:06

ssh -R binds to 127.0.0.1 only on remote

Voir aussi :

A tester : GatewayPorts clientspecified

ssh -R "61027:db1.acme.local:61027" admin@app1.acme.local

Le binding n'est que sur 127.0.0.1

# ss -tlnp | grep 610
LISTEN 0      128        127.0.0.1:61027      0.0.0.0:*    users:(("sshd",pid=3983617,fd=15))                                                                                                                             

Essayons

ssh -g -R "0.0.0.0:61027:db1.acme.local:61027" admin@app1.acme.local

Ca ne marche pas

Idem avec -o GatewayPorts=true

Sur notre machine en écoute sur 127.0.0.1:61027

ssh -g -L 61028:0.0.0.0:61027 localhost

Mais comme nous n'avons pas la clef SSH sur la cible nous faisons :

ssh -A -t admin@app1.acme.local ssh -g -L 61028:0.0.0.0:61027 admin@localhost

Et voilà :

# ss -tlnp | grep 610
LISTEN 0      128        127.0.0.1:61027      0.0.0.0:*    users:(("sshd",pid=3983617,fd=15))                                                            
LISTEN 0      128          0.0.0.0:61028      0.0.0.0:*    users:(("ssh",pid=3987404,fd=6))                                                                  

Autres

Erreurs après un certain temps lors de la connexion

$ ssh -R "61027:db1.acme.local:61027" admin@app1.acme.local
connect_to db1.acme.local port 61027: failed.
connect_to db1.acme.local port 61027: failed.
connect_to db1.acme.local port 61027: failed.
connect_to db1.acme.local port 61027: failed.
2025/03/24 15:06

SSH - l'homme du milieu man-in-the-middle attack - MITM

Voir http://www.phcomp.co.uk/Tutorials/Unix-And-Linux/ssh-check-server-fingerprint.html

/var/log/auth.log

Jan 13 18:08:07 ACME sshd[19573]: Invalid user  from 10.227.01.32
Jan 13 18:08:07 ACME sshd[19573]: input_userauth_request: invalid user  [preauth]
Jan 13 18:08:07 ACME sshd[19573]: Failed none for invalid user  from 10.227.01.32 port 38493 ssh2

Pb

Au début tout commence avec une connexion impossible et une erreur dans /var/log/auth.log Le nom de l'utilisateur n’apparaît pas.

Serveur

for file in *sa_key.pub
  do   ssh-keygen -lf $file
done
1024 82:45:ef:2d:a7:c1:38:30:64:3d:27:5f:07:2d:49:bb ssh_host_dsa_key.pub (DSA)
256 60:1d:11:ae:14:13:91:a6:d6:0c:0b:19:ff:ae:38:50 ssh_host_ecdsa_key.pub (ECDSA)
2048 42:51:fd:3f:d8:5e:ff:0f:7b:b4:ec:00:2b:4f:41:af ssh_host_rsa_key.pub (RSA)

Client

ssh localhost
The authenticity of host 'localhost (::1)' can't be established.
ECDSA key fingerprint is 60:1d:11:ae:14:13:91:a6:d6:0c:0b:19:ff:ae:38:50.
Are you sure you want to continue connecting (yes/no)?

~/.ssh/known_hosts

|1|L/bOL2nijC7tH8OmD3g4wDylRDk=|w2fAVJ4hqgexkcNn1kcQWkWJMwY= ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBBgwV9MaQTOLDDCtn0hRMZQN9398Z4ciwN+mCKN+ZQ47FgXO/ObM5JRUIdZ68th9whxhaGItdAXjFUTpxhUHgyk=

/etc/ssh/ssh_host_ecdsa_key.pub

ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBBgwV9MaQTOLDDCtn0hRMZQN9398Z4ciwN+mCKN+ZQ47FgXO/ObM5JRUIdZ68th9whxhaGItdAXjFUTpxhUHgyk= root@debian2

Avec WinScp

Sur le serveur
#ssh-keygen -E md5 -lf /etc/ssh/ssh_host_ed25519_key.pub
awk '{print $2}' /etc/ssh/ssh_host_ed25519_key.pub | base64 -d | md5sum -b
3284028e26ac8b5eec88ce6d978d8e14 *-
Sur le client

Voir : winscp-mitm.png (FIXME)

FIXME: info manquante

2025/03/24 15:06

Squid - NTLM auth

Voir : https://wiki.squid-cache.org/ConfigExamples/Authenticate/WindowsActiveDirectory

squid.conf

httpd_suppress_version_string on
auth_param ntlm program /usr/bin/ntlm_auth --helper-protocol=squid-2.5-ntlmssp --domain=aspaway.fr
auth_param ntlm children 50
auth_param ntlm keep_alive off

acl ntlm proxy_auth REQUIRED

http_access allow localnet      ntlm
wbinfo -t
wbinfo --ping-dc
 
ntlm_auth --diagnostics --username=jean --domain=acme.fr
2025/03/24 15:06

Notes son-alsa

Voir :

Voir aussi PulseAudio

alsamixer #this sets the simplified Pulseaudio mixer controls
alsamixer -c0 #this sets up the actual ALSA sound card levels
alsamixer -c 0

[F4] pour les entrées son (micros) Input Source Rear Mic

A tester

Si tout est ok en root :

alsactl store

Mettre “Rear Mic” en “Input Source” en ligne de commande

amixer -c0 cset iface=MIXER,name='Input Source',index=0 'Rear Mic'

http://thenerdshow.com/index30e5.html

Ca marche ! Mais j'ai rajoutée cette ligne partout pour la lancer au démarrage du PC, pas moyen. Visiblement qqch change ma config son.

En tapant mate-session-properties (idem que gnome-session-properties, mais pour mate)

Système de son PulseAudio start-pulseaudio-x11

C'est lui le coupable. Je ruse en remplaçant la ligne :

start-pulseaudio-x11; amixer -c0 cset iface=MIXER,name='Input Source',index=0 'Rear Mic'

Ça ne marche pas. Un autre process se lançant au démarrage modifie ma config.

Je ruse en créant un script :

/usr/local/bin/jitsi.sh

#! /bin/bash
 
sleep 15 ; amixer -c0 cset iface=MIXER,name='Input Source',index=0 'Rear Mic'
 
jitsi

C'est lui que j'appelle au démarrage du PC.


Couper le son HP (Mute)

amixer set Master mute

Rétablir le son HP

amixer set Master toggle

Couper le son du micro (Mute)

amixer set Capture nocap

Rétablir le son du micro

amixer set Capture cap

Réduire ou augmenter le son

amixer -D pulse sset Master 50%
amixer set Master 5+

Désactiver le micro

$ cat /proc/asound/modules
 0 snd_hda_intel
 1 snd_hda_intel
echo 'blacklist snd_hda_intel' | sudo tee -a /etc/modprobe.d/blacklist.conf

Autres

Sur Raspbian

/usr/sbin/alsactl -E HOME=/run/alsa -s -n 19 -c rdaemon
Mix
2025/03/24 15:06
blog.txt · Dernière modification : de 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki