Partage
  • Partager sur Facebook
  • Partager sur Twitter

Connexion SSH impossible !

Help

    8 février 2020 à 1:02:16

    Voila ce que j'ai mis comme regle sur la box:

    NomProtocole    IP source      Port source               ip destination  Port destination  
    ssh               TCP  ip de mon tel               22                                   192.168.1.29                             22

    Bonsoir C9H13N,

    Je pensais que je de commentais que si je voulais modifier et que tout etait actif de base. J' y est cru mais toujours pareil.

    #    $OpenBSD: sshd_config,v 1.101 2017/03/14 07:19:07 djm Exp $
     
    # This is the sshd server system-wide configuration file.  See
    # sshd_config(5) for more information.
     
    # This sshd was compiled with PATH=/usr/bin:/bin:/usr/sbin:/sbin
     
    # The strategy used for options in the default sshd_config shipped with
    # OpenSSH is to specify options with their default value where
    # possible, but leave them commented.  Uncommented options override the
    # default value.
     
    Port 22
    #AddressFamily any
    #ListenAddress 0.0.0.0
    #ListenAddress ::
     
    HostKey /etc/ssh/ssh_host_rsa_key
    HostKey /etc/ssh/ssh_host_ecdsa_key
    HostKey /etc/ssh/ssh_host_ed25519_key
     
    # Ciphers and keying
    #RekeyLimit default none
     
    # Logging
    #SyslogFacility AUTH
    #LogLevel INFO
     
    # Authentication:
     
    #LoginGraceTime 2m
    PermitRootLogin yes
    #PermitRootLogin prohibit-password
    #StrictModes yes
    #MaxAuthTries 6
    #MaxSessions 10
     
    PubkeyAuthentication yes
     
    # Expect .ssh/authorized_keys2 to be disregarded by default in future.
    #AuthorizedKeysFile    .ssh/authorized_keys .ssh/authorized_keys2
     
    #AuthorizedPrincipalsFile none
     
    #AuthorizedKeysCommand none
    #AuthorizedKeysCommandUser nobody
     
    # For this to work you will also need host keys in /etc/ssh/ssh_known_hosts
    #HostbasedAuthentication no
    # Change to yes if you don't trust ~/.ssh/known_hosts for
    # HostbasedAuthentication
    #IgnoreUserKnownHosts no
    # Don't read the user's ~/.rhosts and ~/.shosts files
    #IgnoreRhosts yes
     
    # To disable tunneled clear text passwords, change to no here!
    #PasswordAuthentication yes
    #PermitEmptyPasswords no
     
    # Change to yes to enable challenge-response passwords (beware issues with
    # some PAM modules and threads)
    ChallengeResponseAuthentication no
     
    # Kerberos options
    #KerberosAuthentication no
    #KerberosOrLocalPasswd yes
    #KerberosTicketCleanup yes
    #KerberosGetAFSToken no
     
    # GSSAPI options
    #GSSAPIAuthentication no
    #GSSAPICleanupCredentials yes
    #GSSAPIStrictAcceptorCheck yes
    #GSSAPIKeyExchange no
     
    # Set this to 'yes' to enable PAM authentication, account processing,
    # and session processing. If this is enabled, PAM authentication will
    # be allowed through the ChallengeResponseAuthentication and
    # PasswordAuthentication.  Depending on your PAM configuration,
    # PAM authentication via ChallengeResponseAuthentication may bypass
    # the setting of "PermitRootLogin without-password".
    # If you just want the PAM account and session checks to run without
    # PAM authentication, then enable this but set PasswordAuthentication
    # and ChallengeResponseAuthentication to 'no'.
    UsePAM yes
     
    #AllowAgentForwarding yes
    #AllowTcpForwarding yes
    #GatewayPorts no
    X11Forwarding yes
    #X11DisplayOffset 10
    #X11UseLocalhost yes
    #PermitTTY yes
    PrintMotd no
    #PrintLastLog yes
    #TCPKeepAlive yes
    #UseLogin no
    #PermitUserEnvironment no
    #Compression delayed
    #ClientAliveInterval 0
    #ClientAliveCountMax 3
    #UseDNS no
    #PidFile /var/run/sshd.pid
    #MaxStartups 10:30:100
    #PermitTunnel no
    #ChrootDirectory none
    #VersionAddendum none
     
    # no default banner path
    #Banner none
     
    # Allow client to pass locale environment variables
    AcceptEnv LANG LC_*
     
    # override default of no subsystems
    Subsystem    sftp    /usr/lib/openssh/sftp-server
     
    # Example of overriding settings on a per-user basis
    #Match User anoncvs
    #    X11Forwarding no
    #    AllowTcpForwarding no
    #    PermitTTY no
    #    ForceCommand cvs server
    AllowUsers alexandre

    Je n'ai vraiment rien a faire coté client?

    Maintenant ca ne marche meme plus en local. Ca rend trop fou serieux mdrr

    alexandre@msi:~$ ssh alexandre-hp@192.168.1.29
    alexandre-hp@192.168.1.29's password: 
    Permission denied, please try again.
    alexandre-hp@192.168.1.29's password: 
    Permission denied, please try again.
    alexandre-hp@192.168.1.29's password: 
    alexandre-hp@192.168.1.29: Permission denied (publickey,password).

     J ai tout remis en commentaire et ca refonctionne en local...



    -
    Edité par kalounne 8 février 2020 à 1:17:00

    • Partager sur Facebook
    • Partager sur Twitter
      8 février 2020 à 1:09:25

      Normalement, si vous avez authoriser vos router / box à faire le "forwarding", il devrait être ok maintenant.
      Avez-vous redémarré votre router / box ?

      Essayer d’atteindre votre linux avec un ping simple

      Dans le machine avec le SSH server

      ufw status verbose

      Ca vous donne quoi?

      ufw disable




      -
      Edité par C9H13N 8 février 2020 à 1:13:58

      • Partager sur Facebook
      • Partager sur Twitter
        8 février 2020 à 1:18:58

        ufw status verbose  

        sur le serveur

        me donne: état inactif

        Le ping a l air de fonctionner

        PING 111.111.111.1 (111.111.111.1) 56(84) bytes of data.
        64 bytes from 111.111.111.1: icmp_seq=1 ttl=64 time=1.61 ms
        64 bytes from 111.111.111.1: icmp_seq=2 ttl=64 time=2.45 ms
        64 bytes from 1111.111.111.1: icmp_seq=3 ttl=64 time=1.53 ms
        64 bytes from 111.111.111.1: icmp_seq=4 ttl=64 time=1.53 ms
        64 bytes from 111.111.111.1: icmp_seq=5 ttl=64 time=1.55 ms
        64 bytes from 111.111.111.1: icmp_seq=6 ttl=64 time=1.41 ms
        
        -- 111.111.111.1 ping statistics ---
        6 packets transmitted, 6 received, 0% packet loss, time 5008ms
        rtt min/avg/max/mdev = 1.411/1.684/2.456/0.350 ms



        -
        Edité par kalounne 8 février 2020 à 1:27:50

        • Partager sur Facebook
        • Partager sur Twitter
          8 février 2020 à 1:19:41

          C'est bon :) ufw c'est le Firewall

          ping ?

          Permission denied (publickey,password).

          Password -> root / sudo password!

          publickey -> #HostKey /etc/ssh/ssh_host_rsa_key

          Après avoir résolu vos problèmes de connexion, vous pouvez résoudre le problème keygen using

          ssh-keygen -t rsa -b 4096


          Vraiment bizar, votre client normalment rien avoir.

          systemctl status ssh 



          -
          Edité par C9H13N 8 février 2020 à 1:29:24

          • Partager sur Facebook
          • Partager sur Twitter
            8 février 2020 à 1:27:15

            Oui Iptables est tt vide

            Chain INPUT (policy ACCEPT)
            target     prot opt source               destination         
            
            Chain FORWARD (policy ACCEPT)
            target     prot opt source               destination         
            
            Chain OUTPUT (policy ACCEPT)
            target     prot opt source               destination   

             Je n'ai pas compris vortre dernier message dsl:

            Password -> root / sudo password!

            publickey -> #HostKey /etc/ssh/ssh_host_rsa_key

            Après avoir résolu vos problèmes de connexion, vous pouvez résoudre le problème keygen using

            1
            ssh-keygen -t rsa -b 4096

            Que dois je faire doc?

            j obtenais

            Permission denied (publickey,password).
            en local apres avoir decommenter les lignes
            HostKey /etc/ssh/ssh_host_rsa_key
            HostKey /etc/ssh/ssh_host_ecdsa_key
            HostKey /etc/ssh/ssh_host_ed25519_key
            J'ai remis le fichier par defaut et ca refonctionne en local

            -
            Edité par kalounne 8 février 2020 à 1:36:19

            • Partager sur Facebook
            • Partager sur Twitter
              8 février 2020 à 1:40:36

              C'est pour le firewall (mais vos UFW inactif

              iptables -A INPUT -p tcp --dport 22 -j ACCEPT

              ^ pour accepter traffic tcp 22

              iptables -L -v

              ^ pour verifier c'est bien fait.

              Permission denied (publickey,password) <-- inquiter vous pas pour cela.. (c'est le config #PermitRootlogin + #Key....

              • Partager sur Facebook
              • Partager sur Twitter
                8 février 2020 à 1:47:41

                J ai 2 options NAT soit: cones restrictifs sur les ports soit symetrique.

                Par defaut c'est cones restrictifs pour l'instant

                 Voila la manip demandé:

                alexandre-hp@hp:~$ sudo iptables -A INPUT -p tcp --dport 22 -j ACCEPT
                
                alexandre-hp@hp:~$ sudo iptables -L -v
                Chain INPUT (policy ACCEPT 0 packets, 0 bytes)
                 pkts bytes target     prot opt in     out     source               destination         
                    0     0 ACCEPT     tcp  --  any    any     anywhere             anywhere             tcp dpt:ssh
                
                Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
                 pkts bytes target     prot opt in     out     source               destination         
                
                Chain OUTPUT (policy ACCEPT 0 packets, 0 bytes)
                 pkts bytes target     prot opt in     out     source               destination 
                
                



                 Dois je re décommenter ces lignes ??? (car ca ne marche plus en local apres)

                Port 22 
                HostKey /etc/ssh/ssh_host_rsa_key
                HostKey /etc/ssh/ssh_host_ecdsa_key
                HostKey /etc/ssh/ssh_host_ed25519_key


                et commenter celle la:
                #PubkeyAuthentication yes
                ?

                -
                Edité par kalounne 8 février 2020 à 1:59:57

                • Partager sur Facebook
                • Partager sur Twitter
                  8 février 2020 à 1:55:18

                  Restrictif, C'est ok!  symetrique oef.............. hahaha

                  Je suis perdu, Vous pouvez ping l’hôte, SSH est en cours d’exécution, mais vous ne pouvez pas l’atteindre. quelque chose d’autre ne doit pas être ok, je ne peut pas voir quoi.

                  Dsl.

                  Juste pour le debug

                  Installer un serveur httpd, c'est facile à faire. Et essayez d’atteindre http://public_ip

                  Si ca marche, il faut voir avec vos ssh config, jouer un peut la Forwarding etc.. etc..

                  -
                  Edité par C9H13N 8 février 2020 à 10:59:58

                  • Partager sur Facebook
                  • Partager sur Twitter
                    8 février 2020 à 2:03:20

                    Merci,

                    Ca sera pas encore pour ce soir lol

                    J'essayerais

                    Bonne fin de soirée

                    -
                    Edité par kalounne 10 février 2020 à 15:05:19

                    • Partager sur Facebook
                    • Partager sur Twitter
                      8 février 2020 à 11:37:16

                      Dans vos router, Vos DMZ il est activer ?  --->

                      Quick debug (faite dans 3 minute

                      apt install apache2
                      service apache2 start

                      http://192.168.1.1/  <--- vos router

                      Tu dois voir quelque chose comme Ethernet (avec vos Linux box)

                      Example:

                      Portmap Rules

                      Protocol : http

                      port: 80

                      internal ip:  Ip de vos Linux

                      external ip: ip de vos tel

                      Firewall rules dans le router

                      DMZ enable


                      Vos ip public (https://www.whatsmyip.org/ - plus facil pour vous je crois)

                      http://200.156.841.321 <-- VOS IP PUBLIC pas le ip de LINUX!

                      Et voila... ca marche ? Top maintenant vous le faite pour vos SSH :)

                      -
                      Edité par C9H13N 8 février 2020 à 11:38:58

                      • Partager sur Facebook
                      • Partager sur Twitter
                        10 février 2020 à 16:19:20

                        Bonjour C9H13N ,

                        192.168.1.1 ne me permet pas d'acceder à ma box knet, ni freebox mais je me suis connecté à l'interface d'administration par l'espace en ligne et activé la dmz.

                        Je test sur la freebox de mes parents pour voir la différence

                        Je sais reconnaître une adr ip local et internet. Ce n'est pas le problème.

                        La différence c'est que j'ai pu me connecter au pc serveur avec l'adr ip internet de celui-ci mais le client était également sur le reseau wifi de la freebox.

                        alexandre@msi:~$ ssh alexandre-hp@88.120.222.222
                        
                        the authenticity of host '88.120.222.222 (88.120.222.222)' can't be established. ECDSA key fingerprint is SHA256:uBfeQunmjwc1RaDfUnMc4BDJHcXB+zAXexC4Nq3DqZA. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added '88.120.223.93' (ECDSA) to the list of known hosts. alexandre-hp@88.120.222.222's password: Welcome to Ubuntu 18.04.4 LTS (GNU/Linux 5.3.0-28-generic x86_64) * Documentation: https://help.ubuntu.com * Management: https://landscape.canonical.com * Support: https://ubuntu.com/advantage * Canonical Livepatch is available for installation. - Reduce system reboots and improve kernel security. Activate at: https://ubuntu.com/livepatch 0 paquet peut être mis à jour. 0 mise à jour de sécurité. Your Hardware Enablement Stack (HWE) is supported until April 2023. Last login: Mon Feb 10 15:44:14 2020 from 192.168.1.24 alexandre-hp@hp:~$ logout



                        Par contre quand je fait la meme commande mais que je connecte le client au modem de mon telephone, j'ai toujours le message:

                        ssh: connect to host 88.120.222.222 port 22: Connection timed out
                        


                        J'ai alors ouvert une regle de redirection de port sur ma box et cela marche enfin !!!!!!!!!!!!

                        On voit bien que quand je saisi un num de port qui ne correspond pas, j ai un message d'erreur.

                        Mais si je precise le bon numero de port indiquer sur ma box ca passe :D

                        alexandre@msi:~$ ssh -p 16382 alexandre-hp@88.120.222.222
                        ssh: connect to host 88.120.222.222 port 16382: Connection refused
                        alexandre@msi:~$ ssh -p 16387 alexandre-hp@88.120.222.222
                        ssh: connect to host 88.120.222.222 port 16387: Connection refused
                        alexandre@msi:~$ ssh -p 16385 alexandre-hp@88.120.222.222
                        alexandre-hp@88.120.222.222's password: 
                        Welcome to Ubuntu 18.04.4 LTS (GNU/Linux 5.3.0-28-generic x86_64)
                        
                         * Documentation:  https://help.ubuntu.com
                         * Management:     https://landscape.canonical.com
                         * Support:        https://ubuntu.com/advantage
                        
                        
                         * Canonical Livepatch is available for installation.
                           - Reduce system reboots and improve kernel security. Activate at:
                             https://ubuntu.com/livepatch
                        
                        0 paquet peut être mis à jour.
                        0 mise à jour de sécurité.
                        
                        Your Hardware Enablement Stack (HWE) is supported until April 2023.
                        Last login: Mon Feb 10 16:51:04 2020 from 192.168.1.254
                        alexandre-hp@hp:~$ logout
                        Connection to 88.120.222.222 closed.
                        alexandre@msi:~$ 
                        


                        Ca aura été laborieux mais le résulat est la! Reste plus qu'a adapter sur ma box knet.

                        Problème résolu !!

                        Merci à tous pour votre aide ;)

                        -
                        Edité par kalounne 10 février 2020 à 17:23:50

                        • Partager sur Facebook
                        • Partager sur Twitter

                        Connexion SSH impossible !

                        × Après avoir cliqué sur "Répondre" vous serez invité à vous connecter pour que votre message soit publié.
                        × Attention, ce sujet est très ancien. Le déterrer n'est pas forcément approprié. Nous te conseillons de créer un nouveau sujet pour poser ta question.
                        • Editeur
                        • Markdown