Jump to content

Michael_ich

Forum Members
  • Posts

    22
  • Joined

  • Last visited

Posts posted by Michael_ich

  1. Здраствуйте.

    Я использую файл authorized_keys для удаленного выполнения команд на интернет центре.
    Но вот незадача; Через некоторое время права на файлы и каталоги меняются и я не могу авторизоваться по ключу.

    Выяснилось это путем выполнения команд 

    chown -R root:root /opt/etc/dropbear && chmod 600 /opt/etc/dropbear/*
    chown -R root:root /opt && chmod 755 /opt/etc/dropbear/
    /opt/etc/init.d/S51dropbear restart

    После этого все снова начинает работать. Пользователей я не добавлял. Никаких действий через командную строку не производил. Не знаю куда копать, помогите, пожалуйста, разобраться.

    Из установленного только opkg install xupnpd2.

  2. 17 minutes ago, rustrict said:

    Здесь надо или без -i вообще, или -i /root/.ssh/id_rsa.

    Давайте все-таки вернемся к Entware. Появился ли доступ по ключу после моей команды выше? Если нет, то покажите еще права на папки:

    На клиентском устройстве

    
    
    ls -la /root/.ssh

    На роутере

    
    
    ls -la /opt/etc/dropbear

     

    После команды выше не появился.
     

    Spoiler

    bash-5.0# ls -la /root/.ssh
    total 24
    drwx------    2 root     root          4096 Nov 10 15:02 .
    drwx------    1 root     root          4096 Nov 10 15:02 ..
    -rw-------    1 root     root          2602 Nov 10 15:02 id_rsa
    -rw-------    1 root     root           572 Nov 10 15:02 id_rsa.pub
    -rw-r--r--    1 root     root           353 Nov 10 15:17 known_hosts

     

    Spoiler

    ~ # ls -la /opt/etc/dropbear
    drwxrwxr-x    1 root     HA            4096 Nov 10 15:21 .
    drwxrwxr-x    1 root     HA            4096 Nov  9 17:25 ..
    -rw-------    1 root     HA             572 Nov 10 15:21 authorized_keys
    -rwxrwxr-x    1 root     HA             140 Oct 12 18:16 dropbear_ecdsa_host_key
    -rwxrwxr-x    1 root     HA              83 Oct 12 18:16 dropbear_ed25519_host_key
    -rwxrwxr-x    1 root     HA             805 Oct 12 18:16 dropbear_rsa_host_key
     

    log
     

    Spoiler

    bash-5.0# ssh -p '222' 'root@192.168.1.1' -vvv
    OpenSSH_8.3p1, OpenSSL 1.1.1g  21 Apr 2020
    debug1: Reading configuration data /etc/ssh/ssh_config
    debug2: resolve_canonicalize: hostname 192.168.1.1 is address
    debug1: Authenticator provider $SSH_SK_PROVIDER did not resolve; disabling
    debug2: ssh_connect_direct
    debug1: Connecting to 192.168.1.1 [192.168.1.1] port 222.
    debug1: Connection established.
    debug1: identity file /root/.ssh/id_rsa type 0
    debug1: identity file /root/.ssh/id_rsa-cert type -1
    debug1: identity file /root/.ssh/id_dsa type -1
    debug1: identity file /root/.ssh/id_dsa-cert type -1
    debug1: identity file /root/.ssh/id_ecdsa type -1
    debug1: identity file /root/.ssh/id_ecdsa-cert type -1
    debug1: identity file /root/.ssh/id_ecdsa_sk type -1
    debug1: identity file /root/.ssh/id_ecdsa_sk-cert type -1
    debug1: identity file /root/.ssh/id_ed25519 type -1
    debug1: identity file /root/.ssh/id_ed25519-cert type -1
    debug1: identity file /root/.ssh/id_ed25519_sk type -1
    debug1: identity file /root/.ssh/id_ed25519_sk-cert type -1
    debug1: identity file /root/.ssh/id_xmss type -1
    debug1: identity file /root/.ssh/id_xmss-cert type -1
    debug1: Local version string SSH-2.0-OpenSSH_8.3
    debug1: Remote protocol version 2.0, remote software version dropbear
    debug1: no match: dropbear
    debug2: fd 3 setting O_NONBLOCK
    debug1: Authenticating to 192.168.1.1:222 as 'root'
    debug3: put_host_port: [192.168.1.1]:222
    debug3: hostkeys_foreach: reading file "/root/.ssh/known_hosts"
    debug3: record_hostkey: found key type ECDSA in file /root/.ssh/known_hosts:2
    debug3: load_hostkeys: loaded 1 keys from [192.168.1.1]:222
    debug3: order_hostkeyalgs: prefer hostkeyalgs: ecdsa-sha2-nistp256-cert-v01@openssh.com,ecdsa-sha2-nistp384-cert-v01@openssh.com,ecdsa-sha2-nistp521-cert-v01@openssh.com,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521
    debug3: send packet: type 20
    debug1: SSH2_MSG_KEXINIT sent
    debug3: receive packet: type 20
    debug1: SSH2_MSG_KEXINIT received
    debug2: local client KEXINIT proposal
    debug2: KEX algorithms: 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,ext-info-c
    debug2: host key algorithms: ecdsa-sha2-nistp256-cert-v01@openssh.com,ecdsa-sha2-nistp384-cert-v01@openssh.com,ecdsa-sha2-nistp521-cert-v01@openssh.com,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,sk-ecdsa-sha2-nistp256-cert-v01@openssh.com,ssh-ed25519-cert-v01@openssh.com,sk-ssh-ed25519-cert-v01@openssh.com,rsa-sha2-512-cert-v01@openssh.com,rsa-sha2-256-cert-v01@openssh.com,ssh-rsa-cert-v01@openssh.com,sk-ecdsa-sha2-nistp256@openssh.com,ssh-ed25519,sk-ssh-ed25519@openssh.com,rsa-sha2-512,rsa-sha2-256,ssh-rsa
    debug2: ciphers ctos: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com
    debug2: ciphers stoc: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com
    debug2: MACs ctos: 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
    debug2: MACs stoc: 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
    debug2: compression ctos: none,zlib@openssh.com,zlib
    debug2: compression stoc: none,zlib@openssh.com,zlib
    debug2: languages ctos: 
    debug2: languages stoc: 
    debug2: first_kex_follows 0 
    debug2: reserved 0 
    debug2: peer server KEXINIT proposal
    debug2: KEX algorithms: curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp256,diffie-hellman-group14-sha256,diffie-hellman-group14-sha1,kexguess2@matt.ucc.asn.au
    debug2: host key algorithms: ssh-ed25519,ecdsa-sha2-nistp256,rsa-sha2-256,ssh-rsa
    debug2: ciphers ctos: chacha20-poly1305@openssh.com,aes128-ctr,aes256-ctr
    debug2: ciphers stoc: chacha20-poly1305@openssh.com,aes128-ctr,aes256-ctr
    debug2: MACs ctos: hmac-sha1,hmac-sha2-256
    debug2: MACs stoc: hmac-sha1,hmac-sha2-256
    debug2: compression ctos: none
    debug2: compression stoc: none
    debug2: languages ctos: 
    debug2: languages stoc: 
    debug2: first_kex_follows 0 
    debug2: reserved 0 
    debug1: kex: algorithm: curve25519-sha256
    debug1: kex: host key algorithm: ecdsa-sha2-nistp256
    debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
    debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
    debug3: send packet: type 30
    debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
    debug3: receive packet: type 31
    debug1: Server host key: ecdsa-sha2-nistp256 SHA256:9BWRfXLc3Nkgef3/ZH1AjLxYkPYXXGpvWSlXQnOhFHU
    debug3: put_host_port: [192.168.1.1]:222
    debug3: put_host_port: [192.168.1.1]:222
    debug3: hostkeys_foreach: reading file "/root/.ssh/known_hosts"
    debug3: record_hostkey: found key type ECDSA in file /root/.ssh/known_hosts:2
    debug3: load_hostkeys: loaded 1 keys from [192.168.1.1]:222
    debug3: hostkeys_foreach: reading file "/root/.ssh/known_hosts"
    debug3: record_hostkey: found key type ECDSA in file /root/.ssh/known_hosts:2
    debug3: load_hostkeys: loaded 1 keys from [192.168.1.1]:222
    debug1: Host '[192.168.1.1]:222' is known and matches the ECDSA host key.
    debug1: Found key in /root/.ssh/known_hosts:2
    debug3: send packet: type 21
    debug2: set_newkeys: mode 1
    debug1: rekey out after 134217728 blocks
    debug1: SSH2_MSG_NEWKEYS sent
    debug1: expecting SSH2_MSG_NEWKEYS
    debug3: receive packet: type 21
    debug1: SSH2_MSG_NEWKEYS received
    debug2: set_newkeys: mode 0
    debug1: rekey in after 134217728 blocks
    debug1: Will attempt key: /root/.ssh/id_rsa RSA SHA256:am2b3n+E46I/+9MBE1qRgbJJAL1NH3AKZ3P0EvTDS4k
    debug1: Will attempt key: /root/.ssh/id_dsa 
    debug1: Will attempt key: /root/.ssh/id_ecdsa 
    debug1: Will attempt key: /root/.ssh/id_ecdsa_sk 
    debug1: Will attempt key: /root/.ssh/id_ed25519 
    debug1: Will attempt key: /root/.ssh/id_ed25519_sk 
    debug1: Will attempt key: /root/.ssh/id_xmss 
    debug2: pubkey_prepare: done
    debug3: send packet: type 5
    debug3: receive packet: type 7
    debug1: SSH2_MSG_EXT_INFO received
    debug1: kex_input_ext_info: server-sig-algs=<ssh-ed25519,ecdsa-sha2-nistp256,rsa-sha2-256,ssh-rsa>
    debug3: receive packet: type 6
    debug2: service_accept: ssh-userauth
    debug1: SSH2_MSG_SERVICE_ACCEPT received
    debug3: send packet: type 50
    debug3: receive packet: type 51
    debug1: Authentications that can continue: publickey,password
    debug3: start over, passed a different list publickey,password
    debug3: preferred publickey,keyboard-interactive,password
    debug3: authmethod_lookup publickey
    debug3: remaining preferred: keyboard-interactive,password
    debug3: authmethod_is_enabled publickey
    debug1: Next authentication method: publickey
    debug1: Offering public key: /root/.ssh/id_rsa RSA SHA256:am2b3n+E46I/+9MBE1qRgbJJAL1NH3AKZ3P0EvTDS4k
    debug3: send packet: type 50
    debug2: we sent a publickey packet, wait for reply
    debug3: receive packet: type 51
    debug1: Authentications that can continue: publickey,password
    debug1: Trying private key: /root/.ssh/id_dsa
    debug3: no such identity: /root/.ssh/id_dsa: No such file or directory
    debug1: Trying private key: /root/.ssh/id_ecdsa
    debug3: no such identity: /root/.ssh/id_ecdsa: No such file or directory
    debug1: Trying private key: /root/.ssh/id_ecdsa_sk
    debug3: no such identity: /root/.ssh/id_ecdsa_sk: No such file or directory
    debug1: Trying private key: /root/.ssh/id_ed25519
    debug3: no such identity: /root/.ssh/id_ed25519: No such file or directory
    debug1: Trying private key: /root/.ssh/id_ed25519_sk
    debug3: no such identity: /root/.ssh/id_ed25519_sk: No such file or directory
    debug1: Trying private key: /root/.ssh/id_xmss
    debug3: no such identity: /root/.ssh/id_xmss: No such file or directory
    debug2: we did not send a packet, disable method
    debug3: authmethod_lookup password
    debug3: remaining preferred: ,password
    debug3: authmethod_is_enabled password
    debug1: Next authentication method: password
    root@192.168.1.1's password: 

     

  3. 13 minutes ago, rustrict said:

    Пока я заметил, что вы переносили ключ не из той папки, которую проверяет ssh. Попробуйте:

    
    
    cat /root/.ssh/id_rsa.pub | ssh -p 222 root@192.168.1.1 "cat > /opt/etc/dropbear/authorized_keys && chmod 600 /opt/etc/dropbear/authorized_keys"

     

    Решил переключится и попробовать по новой на малинке
    ssh -i /root/.ssh/id_rsa.pub -p '22' 'michael@192.168.1.11' -vvv

    Spoiler

    bash-5.0# ssh -i /root/.ssh/id_rsa.pub -p '22' 'michael@192.168.1.11' -vvv
    OpenSSH_8.3p1, OpenSSL 1.1.1g  21 Apr 2020
    debug1: Reading configuration data /etc/ssh/ssh_config
    debug2: resolve_canonicalize: hostname 192.168.1.11 is address
    debug1: Authenticator provider $SSH_SK_PROVIDER did not resolve; disabling
    debug2: ssh_connect_direct
    debug1: Connecting to 192.168.1.11 [192.168.1.11] port 22.
    debug1: Connection established.
    debug1: identity file /root/.ssh/id_rsa.pub type 0
    debug1: identity file /root/.ssh/id_rsa.pub-cert type -1
    debug1: Local version string SSH-2.0-OpenSSH_8.3
    debug1: Remote protocol version 2.0, remote software version OpenSSH_7.9p1 Raspbian-10+deb10u2
    debug1: match: OpenSSH_7.9p1 Raspbian-10+deb10u2 pat OpenSSH* compat 0x04000000
    debug2: fd 3 setting O_NONBLOCK
    debug1: Authenticating to 192.168.1.11:22 as 'michael'
    debug3: hostkeys_foreach: reading file "/root/.ssh/known_hosts"
    debug3: record_hostkey: found key type ECDSA in file /root/.ssh/known_hosts:1
    debug3: load_hostkeys: loaded 1 keys from 192.168.1.11
    debug3: order_hostkeyalgs: prefer hostkeyalgs: ecdsa-sha2-nistp256-cert-v01@openssh.com,ecdsa-sha2-nistp384-cert-v01@openssh.com,ecdsa-sha2-nistp521-cert-v01@openssh.com,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521
    debug3: send packet: type 20
    debug1: SSH2_MSG_KEXINIT sent
    debug3: receive packet: type 20
    debug1: SSH2_MSG_KEXINIT received
    debug2: local client KEXINIT proposal
    debug2: KEX algorithms: 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,ext-info-c
    debug2: host key algorithms: ecdsa-sha2-nistp256-cert-v01@openssh.com,ecdsa-sha2-nistp384-cert-v01@openssh.com,ecdsa-sha2-nistp521-cert-v01@openssh.com,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,sk-ecdsa-sha2-nistp256-cert-v01@openssh.com,ssh-ed25519-cert-v01@openssh.com,sk-ssh-ed25519-cert-v01@openssh.com,rsa-sha2-512-cert-v01@openssh.com,rsa-sha2-256-cert-v01@openssh.com,ssh-rsa-cert-v01@openssh.com,sk-ecdsa-sha2-nistp256@openssh.com,ssh-ed25519,sk-ssh-ed25519@openssh.com,rsa-sha2-512,rsa-sha2-256,ssh-rsa
    debug2: ciphers ctos: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com
    debug2: ciphers stoc: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com
    debug2: MACs ctos: 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
    debug2: MACs stoc: 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
    debug2: compression ctos: none,zlib@openssh.com,zlib
    debug2: compression stoc: none,zlib@openssh.com,zlib
    debug2: languages ctos: 
    debug2: languages stoc: 
    debug2: first_kex_follows 0 
    debug2: reserved 0 
    debug2: peer server KEXINIT proposal
    debug2: KEX algorithms: 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
    debug2: host key algorithms: rsa-sha2-512,rsa-sha2-256,ssh-rsa,ecdsa-sha2-nistp256,ssh-ed25519
    debug2: ciphers ctos: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com
    debug2: ciphers stoc: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com
    debug2: MACs ctos: 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
    debug2: MACs stoc: 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
    debug2: compression ctos: none,zlib@openssh.com
    debug2: compression stoc: none,zlib@openssh.com
    debug2: languages ctos: 
    debug2: languages stoc: 
    debug2: first_kex_follows 0 
    debug2: reserved 0 
    debug1: kex: algorithm: curve25519-sha256
    debug1: kex: host key algorithm: ecdsa-sha2-nistp256
    debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
    debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
    debug3: send packet: type 30
    debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
    debug3: receive packet: type 31
    debug1: Server host key: ecdsa-sha2-nistp256 SHA256:sJS7Q7IEyA1G/1atSR5dklAFo7aGfcpUE3dtQwS1Yc4
    debug3: hostkeys_foreach: reading file "/root/.ssh/known_hosts"
    debug3: record_hostkey: found key type ECDSA in file /root/.ssh/known_hosts:1
    debug3: load_hostkeys: loaded 1 keys from 192.168.1.11
    debug1: Host '192.168.1.11' is known and matches the ECDSA host key.
    debug1: Found key in /root/.ssh/known_hosts:1
    debug3: send packet: type 21
    debug2: set_newkeys: mode 1
    debug1: rekey out after 134217728 blocks
    debug1: SSH2_MSG_NEWKEYS sent
    debug1: expecting SSH2_MSG_NEWKEYS
    debug3: receive packet: type 21
    debug1: SSH2_MSG_NEWKEYS received
    debug2: set_newkeys: mode 0
    debug1: rekey in after 134217728 blocks
    debug1: Will attempt key: /root/.ssh/id_rsa.pub RSA SHA256:am2b3n+E46I/+9MBE1qRgbJJAL1NH3AKZ3P0EvTDS4k explicit
    debug2: pubkey_prepare: done
    debug3: send packet: type 5
    debug3: receive packet: type 7
    debug1: SSH2_MSG_EXT_INFO received
    debug1: kex_input_ext_info: server-sig-algs=<ssh-ed25519,ssh-rsa,rsa-sha2-256,rsa-sha2-512,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521>
    debug3: receive packet: type 6
    debug2: service_accept: ssh-userauth
    debug1: SSH2_MSG_SERVICE_ACCEPT received
    debug3: send packet: type 50
    debug3: receive packet: type 51
    debug1: Authentications that can continue: publickey,password
    debug3: start over, passed a different list publickey,password
    debug3: preferred publickey,keyboard-interactive,password
    debug3: authmethod_lookup publickey
    debug3: remaining preferred: keyboard-interactive,password
    debug3: authmethod_is_enabled publickey
    debug1: Next authentication method: publickey
    debug1: Offering public key: /root/.ssh/id_rsa.pub RSA SHA256:am2b3n+E46I/+9MBE1qRgbJJAL1NH3AKZ3P0EvTDS4k explicit
    debug3: send packet: type 50
    debug2: we sent a publickey packet, wait for reply
    debug3: receive packet: type 60
    debug1: Server accepts key: /root/.ssh/id_rsa.pub RSA SHA256:am2b3n+E46I/+9MBE1qRgbJJAL1NH3AKZ3P0EvTDS4k explicit
    debug3: sign_and_send_pubkey: RSA SHA256:am2b3n+E46I/+9MBE1qRgbJJAL1NH3AKZ3P0EvTDS4k
    debug3: sign_and_send_pubkey: signing using rsa-sha2-512 SHA256:am2b3n+E46I/+9MBE1qRgbJJAL1NH3AKZ3P0EvTDS4k
    Load key "/root/.ssh/id_rsa.pub": invalid format
    debug2: we did not send a packet, disable method
    debug3: authmethod_lookup password
    debug3: remaining preferred: ,password
    debug3: authmethod_is_enabled password
    debug1: Next authentication method: password
    michael@192.168.1.11's password: 

    Что может быть с форматом не знаю
    Генерил просто ssh-keygen без параметров

     

    bash-5.0# cat id_rsa.pub 
    ssh-rsa AA.............................0= root@homeassistant

  4. 1 hour ago, rustrict said:

    Это не так:

    
    Compatible with OpenSSH ~/.ssh/authorized_keys public key authentication

    Я вам в другой теме предложил посмотреть лог подключения. Проверьте, например, что в ряду PreferredAuthentications publickey стоит впереди password:

    
    debug3: preferred publickey,keyboard-interactive,password

     

    Выдает следующее
     

    Spoiler

    bash-5.0# ssh -p '222' 'root@192.168.1.1' -vvv
    OpenSSH_8.3p1, OpenSSL 1.1.1g  21 Apr 2020
    debug1: Reading configuration data /etc/ssh/ssh_config
    debug2: resolve_canonicalize: hostname 192.168.1.1 is address
    debug1: Authenticator provider $SSH_SK_PROVIDER did not resolve; disabling
    debug2: ssh_connect_direct
    debug1: Connecting to 192.168.1.1 [192.168.1.1] port 222.
    debug1: Connection established.
    debug1: identity file /root/.ssh/id_rsa type 0
    debug1: identity file /root/.ssh/id_rsa-cert type -1
    debug1: identity file /root/.ssh/id_dsa type -1
    debug1: identity file /root/.ssh/id_dsa-cert type -1
    debug1: identity file /root/.ssh/id_ecdsa type -1
    debug1: identity file /root/.ssh/id_ecdsa-cert type -1
    debug1: identity file /root/.ssh/id_ecdsa_sk type -1
    debug1: identity file /root/.ssh/id_ecdsa_sk-cert type -1
    debug1: identity file /root/.ssh/id_ed25519 type -1
    debug1: identity file /root/.ssh/id_ed25519-cert type -1
    debug1: identity file /root/.ssh/id_ed25519_sk type -1
    debug1: identity file /root/.ssh/id_ed25519_sk-cert type -1
    debug1: identity file /root/.ssh/id_xmss type -1
    debug1: identity file /root/.ssh/id_xmss-cert type -1
    debug1: Local version string SSH-2.0-OpenSSH_8.3
    debug1: Remote protocol version 2.0, remote software version dropbear
    debug1: no match: dropbear
    debug2: fd 3 setting O_NONBLOCK
    debug1: Authenticating to 192.168.1.1:222 as 'root'
    debug3: put_host_port: [192.168.1.1]:222
    debug3: hostkeys_foreach: reading file "/root/.ssh/known_hosts"
    debug3: record_hostkey: found key type ECDSA in file /root/.ssh/known_hosts:1
    debug3: load_hostkeys: loaded 1 keys from [192.168.1.1]:222
    debug3: order_hostkeyalgs: prefer hostkeyalgs: ecdsa-sha2-nistp256-cert-v01@openssh.com,ecdsa-sha2-nistp384-cert-v01@openssh.com,ecdsa-sha2-nistp521-cert-v01@openssh.com,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521
    debug3: send packet: type 20
    debug1: SSH2_MSG_KEXINIT sent
    debug3: receive packet: type 20
    debug1: SSH2_MSG_KEXINIT received
    debug2: local client KEXINIT proposal
    debug2: KEX algorithms: 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,ext-info-c
    debug2: host key algorithms: ecdsa-sha2-nistp256-cert-v01@openssh.com,ecdsa-sha2-nistp384-cert-v01@openssh.com,ecdsa-sha2-nistp521-cert-v01@openssh.com,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,sk-ecdsa-sha2-nistp256-cert-v01@openssh.com,ssh-ed25519-cert-v01@openssh.com,sk-ssh-ed25519-cert-v01@openssh.com,rsa-sha2-512-cert-v01@openssh.com,rsa-sha2-256-cert-v01@openssh.com,ssh-rsa-cert-v01@openssh.com,sk-ecdsa-sha2-nistp256@openssh.com,ssh-ed25519,sk-ssh-ed25519@openssh.com,rsa-sha2-512,rsa-sha2-256,ssh-rsa
    debug2: ciphers ctos: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com
    debug2: ciphers stoc: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com
    debug2: MACs ctos: 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
    debug2: MACs stoc: 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
    debug2: compression ctos: none,zlib@openssh.com,zlib
    debug2: compression stoc: none,zlib@openssh.com,zlib
    debug2: languages ctos: 
    debug2: languages stoc: 
    debug2: first_kex_follows 0 
    debug2: reserved 0 
    debug2: peer server KEXINIT proposal
    debug2: KEX algorithms: curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp256,diffie-hellman-group14-sha256,diffie-hellman-group14-sha1,kexguess2@matt.ucc.asn.au
    debug2: host key algorithms: ssh-ed25519,ecdsa-sha2-nistp256,rsa-sha2-256,ssh-rsa
    debug2: ciphers ctos: chacha20-poly1305@openssh.com,aes128-ctr,aes256-ctr
    debug2: ciphers stoc: chacha20-poly1305@openssh.com,aes128-ctr,aes256-ctr
    debug2: MACs ctos: hmac-sha1,hmac-sha2-256
    debug2: MACs stoc: hmac-sha1,hmac-sha2-256
    debug2: compression ctos: none
    debug2: compression stoc: none
    debug2: languages ctos: 
    debug2: languages stoc: 
    debug2: first_kex_follows 0 
    debug2: reserved 0 
    debug1: kex: algorithm: curve25519-sha256
    debug1: kex: host key algorithm: ecdsa-sha2-nistp256
    debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
    debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
    debug3: send packet: type 30
    debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
    debug3: receive packet: type 31
    debug1: Server host key: ecdsa-sha2-nistp256 SHA256:9BWRfXLc3Nkgef3/ZH1AjLxYkPYXXGpvWSlXQnOhFHU
    debug3: put_host_port: [192.168.1.1]:222
    debug3: put_host_port: [192.168.1.1]:222
    debug3: hostkeys_foreach: reading file "/root/.ssh/known_hosts"
    debug3: record_hostkey: found key type ECDSA in file /root/.ssh/known_hosts:1
    debug3: load_hostkeys: loaded 1 keys from [192.168.1.1]:222
    debug3: hostkeys_foreach: reading file "/root/.ssh/known_hosts"
    debug3: record_hostkey: found key type ECDSA in file /root/.ssh/known_hosts:1
    debug3: load_hostkeys: loaded 1 keys from [192.168.1.1]:222
    debug1: Host '[192.168.1.1]:222' is known and matches the ECDSA host key.
    debug1: Found key in /root/.ssh/known_hosts:1
    debug3: send packet: type 21
    debug2: set_newkeys: mode 1
    debug1: rekey out after 134217728 blocks
    debug1: SSH2_MSG_NEWKEYS sent
    debug1: expecting SSH2_MSG_NEWKEYS
    debug3: receive packet: type 21
    debug1: SSH2_MSG_NEWKEYS received
    debug2: set_newkeys: mode 0
    debug1: rekey in after 134217728 blocks
    debug1: Will attempt key: /root/.ssh/id_rsa RSA SHA256:qvRNyydFqnVmaBYZkH3+GHFpnPZt5R1YmenSJfpI2KM
    debug1: Will attempt key: /root/.ssh/id_dsa 
    debug1: Will attempt key: /root/.ssh/id_ecdsa 
    debug1: Will attempt key: /root/.ssh/id_ecdsa_sk 
    debug1: Will attempt key: /root/.ssh/id_ed25519 
    debug1: Will attempt key: /root/.ssh/id_ed25519_sk 
    debug1: Will attempt key: /root/.ssh/id_xmss 
    debug2: pubkey_prepare: done
    debug3: send packet: type 5
    debug3: receive packet: type 7
    debug1: SSH2_MSG_EXT_INFO received
    debug1: kex_input_ext_info: server-sig-algs=<ssh-ed25519,ecdsa-sha2-nistp256,rsa-sha2-256,ssh-rsa>
    debug3: receive packet: type 6
    debug2: service_accept: ssh-userauth
    debug1: SSH2_MSG_SERVICE_ACCEPT received
    debug3: send packet: type 50
    debug3: receive packet: type 51
    debug1: Authentications that can continue: publickey,password
    debug3: start over, passed a different list publickey,password
    debug3: preferred publickey,keyboard-interactive,password
    debug3: authmethod_lookup publickey
    debug3: remaining preferred: keyboard-interactive,password
    debug3: authmethod_is_enabled publickey
    debug1: Next authentication method: publickey
    debug1: Offering public key: /root/.ssh/id_rsa RSA SHA256:qvRNyydFqnVmaBYZkH3+GHFpnPZt5R1YmenSJfpI2KM
    debug3: send packet: type 50
    debug2: we sent a publickey packet, wait for reply
    debug3: receive packet: type 51
    debug1: Authentications that can continue: publickey,password
    debug1: Trying private key: /root/.ssh/id_dsa
    debug3: no such identity: /root/.ssh/id_dsa: No such file or directory
    debug1: Trying private key: /root/.ssh/id_ecdsa
    debug3: no such identity: /root/.ssh/id_ecdsa: No such file or directory
    debug1: Trying private key: /root/.ssh/id_ecdsa_sk
    debug3: no such identity: /root/.ssh/id_ecdsa_sk: No such file or directory
    debug1: Trying private key: /root/.ssh/id_ed25519
    debug3: no such identity: /root/.ssh/id_ed25519: No such file or directory
    debug1: Trying private key: /root/.ssh/id_ed25519_sk
    debug3: no such identity: /root/.ssh/id_ed25519_sk: No such file or directory
    debug1: Trying private key: /root/.ssh/id_xmss
    debug3: no such identity: /root/.ssh/id_xmss: No such file or directory
    debug2: we did not send a packet, disable method
    debug3: authmethod_lookup password
    debug3: remaining preferred: ,password
    debug3: authmethod_is_enabled password
    debug1: Next authentication method: password
    root@192.168.1.1's password: 

     

  5. Проблема похоже оказалась в параметрах запуска dropbear. нужно указать -s

     

    в /opt/etc/init.d/SXXdropbear (где ХХ - две цифры исходя из конкретной конфигурации) нужно исправить функцию start() на

    $DROPBEAR -s -p $PORT -P $PIDFILE

    Но тогда не зайти по паролю. А мне нужно и по паролю и по ключу.

    UPDT
    Тут мне подсказали, что  ключи openssh не подходят к dropbear
    Видимо в этом проблема

  6. On 5/2/2020 at 10:43 PM, rustrict said:

    К прошивочному dropbear — нет. Если есть возможность использовать Entware, то там authorized_keys работают. Подключаетесь, запускаете ndmc и вы в CLI.

    На Entware поставленный по этой инструкции закинул ключ
    Передвинул mv /opt/root/.ssh/authorized_keys /opt/etc/dropbear

    Сделал /opt/etc/init.d/S51dropbear restart

    Все равно просит пароль. Что не так?

  7. Здраствуйте, уважаемые форумчане.

    Знаю, обсуждалось, было. Читал, смотрел, искал, но успеха не добился.
    Подскажите как авторизоваться без пароля (по shh) на интрент центре?


    Поставил entware по этой инструкции. Сгенерировал ключи. Перенес на интрент центр

    ssh-copy-id -i /config/.ssh/id_rsa.pub root@192.168.1.1 -p 222

    Без пароля не заработало

    ssh -i /config/.ssh/id_rsa root@192.168.1.1 -p 222


    Передвинул ключи 

    mv /opt/root/.ssh/authorized_keys /opt/etc/dropbear

    Снова попытался выполнить 

    ssh -i /config/.ssh/id_rsa root@192.168.1.1 -p 222

    Не срабатывает.

    Команды

    cd /opt/etc/dropbear/
    chmod 600 authorized_keys

    выполнял.


    Что может быть не так? Интрент центр перезагружал. Как отдельно перезагрузить dropbear не знаю.

  8. On 10/30/2020 at 4:04 PM, laforsh said:

    Хотя... Если его там нет, то зайти на на докер и дать команду копирования ключа на роутер:

    ssh-copy-id -i ./config/.ssh/id_rsa.pub root@IP адрес роутера

    Потом на роутере

    mv /root/.ssh/authorized_keys /etc/dropbear

     

    mv /opt/root/.ssh/authorized_keys /opt/etc/dropbear

    Файил authorized_keys передвинулся. Я его вижу командой cat /opt/etc/dropbear/authorized_keys

    Но

    ssh -i /config/.ssh/id_rsa root@192.168.1.1 -p 222

    все равно просит пароль

  9. 4 minutes ago, laforsh said:

    ОК, какой ssh сервер стоит на роутере ? dropbear (который используется по умолчанию в инструкции по установке entware) или отдельно ставили openssh-server ? Если не знаете, то зайдите через putty по ssh на роутер и дайте сюда под спойлер выхлоп ls -l /etc  и ls -l /etc/ssh

     

    ~ # ls -l /etc
    lrwxrwxrwx    1 root     root             7 Oct 30 11:17 TZ -> /var/TZ
    -rw-r--r--    1 root     root         37952 Oct 30 11:17 components.xml
    -rw-r--r--    1 root     root           805 Oct 19 18:52 devices
    lrwxrwxrwx    1 root     root            10 Oct 30 11:17 group -> /tmp/group
    lrwxrwxrwx    1 root     root            18 Oct 30 11:17 host.conf -> /opt/etc/host.conf
    lrwxrwxrwx    1 root     root            10 Oct 30 11:17 hosts -> /var/hosts
    lrwxrwxrwx    1 root     root             7 Oct 30 11:17 localtime -> /var/TZ
    -rw-r--r--    1 root     root          1061 Oct 30 11:17 modules.autoload
    lrwxrwxrwx    1 root     root            12 Oct 30 11:17 mtab -> /proc/mounts
    drwxr-xr-x    2 root     root           123 Oct 30 11:17 nginx
    lrwxrwxrwx    1 root     root            22 Oct 30 11:17 nsswitch.conf -> /opt/etc/nsswitch.conf
    lrwxrwxrwx    1 root     root            11 Oct 30 11:17 passwd -> /tmp/passwd
    lrwxrwxrwx    1 root     root             8 Oct 30 11:17 ppp -> /var/ppp
    lrwxrwxrwx    1 root     root            16 Oct 30 11:17 preinit -> /opt/etc/preinit
    lrwxrwxrwx    1 root     root            16 Oct 30 11:17 profile -> /opt/etc/profile
    -rw-r--r--    1 root     root          5552 Oct 19 18:52 protocols
    lrwxrwxrwx    1 root     root            18 Oct 30 11:17 rc.common -> /opt/etc/rc.common
    lrwxrwxrwx    1 root     root            16 Oct 30 11:17 resolv.conf -> /var/resolv.conf
    -rw-r--r--    1 root     root         18105 Oct 19 18:52 services
    lrwxrwxrwx    1 root     root            15 Oct 30 11:17 shells -> /opt/etc/shells
    drwxr-xr-x    4 root     root            59 Oct 30 11:17 ssl
    -rw-r--r--    1 root     root           211 Oct 19 19:31 strongswan.conf
    drwxr-xr-x    3 root     root            29 Oct 30 11:17 strongswan.d
    lrwxrwxrwx    1 root     root            21 Oct 30 11:17 uci-defaults -> /opt/etc/uci-defaults
    drwxr-xr-x    2 root     root           222 Oct 30 11:17 wlan
    ~ # ls -l /etc/ssh
    ls: /etc/ssh: No such file or directory

    Отдельно ничего не ставил

  10. 9 minutes ago, laforsh said:

     

    Теория у Вас немного хромает. sshd должен быть установлен на роутере (как рация - на бронепоезде). Почитайте до понимания статью https://help.ubuntu.ru/wiki/ssh

    "Выполнение команд через ssh в entware/debian" и "выполнение команд через telnet в cli кинетика" - это две большие разницы. С sshd из прошивки вряд ли чем помогу, ибо не использую и не знаю его настроек. С sshd из entware или debian (как будет понимание что делаем и когда они будут установлены на роутер) - пишите, чем смогу. Постоянно пользуюсь такой схемой запуска команд на удаленных серверах.

    Судя по фразе

    вы на полпути к цели. Ключ не скопировался (или не подхватился сервером), но какой-то sshd на вашем роутере все таки имеется. И, кстати, ваша команда "interface OpenVPN0 down" отрабатывает как нужно ?

    На интрент центре уже стоит entware по этой инструкции.

    "interface OpenVPN0 down" отрабатывает как нужно в cli кинетика

    В entware 

    BusyBox v1.31.1 () built-in shell (ash)
    
    ~ # interface OpenVPN0 down
    -sh: interface: not found
    ~ #

     

  11. Проверил на докер контейнере отпечаток ключа
    ssh-keygen -lf /config/.ssh/id_rsa.pub
    И сравнил с  show ssh fingerprint с интернет центра

    Совпадений нет.

    PS
    sshpass пробовал. Он к сожалению отсутствует в данном контейнере как и телнет

  12. 17 minutes ago, laforsh said:

    sshd сервер какой ? Прошивочный, entware, debian, gentoo и т.д. ?

    В /etc/sshd_config раскомментирована строка:

    # Expect .ssh/authorized_keys2 to be disregarded by default in future.
    AuthorizedKeysFile<--->.ssh/authorized_keys .ssh/authorized_keys2

    На кинетике user создан ?

    Если зайти на кинетик в /home/user/.ssh/authorized_keys лежит ?

     

    Извиняюсь, не все вопросы понятны.
    Речь идёт про Home Assistant в докер контейнере.

    USER создан.


    /home/user/.ssh/authorized_keys проверить не получается. Т.к. команды cd, ls - l и многие другие не выполняются

    Строка В /etc/sshd_config на интрент центре? 

    KeeneticOS version 3.05.C.2.0-1, copyright (c) 2010-2020 Keenetic Ltd.
    
    
    THIS SOFTWARE IS A SUBJECT OF KEENETIC LIMITED END-USER LICENCE AGREEMENT. BY
    USING IT YOU AGREE ON TERMS AND CONDITIONS HEREOF. FOR MORE INFORMATION PLEASE
    CHECK https://keenetic.com/legal
    
    (config)> cd
    Command::Base error[7405600]: no such command: cd.
    (config)> cat
    (config)> ls -l
    Command::Base error[7405602]: directory: argument parse error.
    (config)> cat /etc/sshd_config
    (config)>

     

  13. Доброго времени суток.

    Имеется контейнер в docker под Linux (с ограниченным функционалом) из которого я бы хотел посылать команды на интернет центр keenetic ultra на включение и отключение интерфейсов (VPN).
    Установить Telnet на этот контейнер нельзя. Зато есть SSH.
    Собственно им я и воспользовался:
    Сгенерил ключи в докер контейнере

    bash-5.0# ssh-keygen


    Скопировал ключи на желаемый host

    ssh-copy-id -i /config/.ssh/id_rsa.pub pi@192.168.1.1


    Тут меня постигла неудача.
    Команда

    bash-5.0# ssh -i /config/.ssh/id_rsa user@192.168.1.1 interface OpenVPN0 down

    выполняется, но не автоматом. Интрнет центр не проводит авторизацию по ключу, и всё-равно просит пароль.

    Подскажите, пожалуйста, как я могу управлять интерфейсами интрнет центра из командной строки docker конейнера без авторизации по паролю, если описанный метод авторизации по ключю не работает?

    PS в контейнере есть curl

  14. Добрый день. 

    Являюсь обладателем нового keenetic ultra. На интернет центре настроено vpn  подключение. Очень неудобно каждый раз заходить на веб морду и включать vpn в интерфейсе. Подскажите, пожалуйста, как включать/выключать vpn/openvpn подключение командами через  telnet?

    Почитал документацию по командам, не смог разобраться. 

×
×
  • Create New...