AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • Início
  • system&network
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • Início
  • system&network
    • Recentes
    • Highest score
    • tags
  • Ubuntu
    • Recentes
    • Highest score
    • tags
  • Unix
    • Recentes
    • tags
  • DBA
    • Recentes
    • tags
  • Computer
    • Recentes
    • tags
  • Coding
    • Recentes
    • tags
Início / server / Perguntas / 1163011
Accepted
Darrell Brogdon
Darrell Brogdon
Asked: 2024-07-25 02:13:59 +0800 CST2024-07-25 02:13:59 +0800 CST 2024-07-25 02:13:59 +0800 CST

Por que estou recebendo uma “Permissão negada (chave pública)” no Azure Ubuntu?

  • 772

Tenho um servidor Ubuntu 24.04 configurado no Azure. A chave gerada quando configurei a instância funciona. Criei então um novo usuário (dbrogdon) e gerei uma nova chave com o mesmo tipo de chave (Ed25519). Em seguida, copiei a chave pública para ~dbrogdon/.ssh/authorized_keys e alterei as permissões para o seguinte:

drwx------ 2 dbrogdon dbrogdon 4.0K Jul 24 17:21 .
drwxr-x--- 3 dbrogdon dbrogdon 4.0K Jul 24 17:22 ..
-rw------- 1 dbrogdon dbrogdon  104 Jul 24 17:20 authorized_keys

No meu Mac, tenho a chave privada com as seguintes permissões:

-rw-------  1 dbrogdon  staff   419B Jul 24 10:51 dbrogdon-key.pem

Quando tento fazer ssh do meu Mac para o servidor, recebo o seguinte:

debug1: Host 'xxxxxxx' is known and matches the ED25519 host key.
debug1: Found key in /Users/dbrogdon/.ssh/known_hosts:53
debug1: ssh_packet_send2_wrapped: resetting send seqnr 3
debug1: rekey out after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: Sending SSH2_MSG_EXT_INFO
debug1: expecting SSH2_MSG_NEWKEYS
debug1: ssh_packet_read_poll2: resetting read seqnr 3
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey in after 134217728 blocks
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_ext_info_client_parse: server-sig-algs=<ssh-ed25519,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,[email protected],[email protected],rsa-sha2-512,rsa-sha2-256>
debug1: kex_ext_info_check_ver: [email protected]=<0>
debug1: kex_ext_info_check_ver: [email protected]=<0>
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_ext_info_client_parse: server-sig-algs=<ssh-ed25519,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,[email protected],[email protected],rsa-sha2-512,rsa-sha2-256>
debug1: Authentications that can continue: publickey
debug1: No more authentication methods to try.

Aqui está o auth.log para essa sessão:

2024-07-24T18:09:51.877109+00:00 xxxxxxx sshd[3349]: Connection from 71.205.127.54 port 52988 on 10.1.0.4 port 22 rdomain ""
2024-07-24T18:09:51.877153+00:00 xxxxxxx sshd[3349]: debug1: Local version string SSH-2.0-OpenSSH_9.6p1 Ubuntu-3ubuntu13.4
2024-07-24T18:09:51.877191+00:00 xxxxxxx sshd[3349]: debug1: Remote protocol version 2.0, remote software version OpenSSH_9.6
2024-07-24T18:09:51.877240+00:00 xxxxxxx sshd[3349]: debug1: compat_banner: match: OpenSSH_9.6 pat OpenSSH* compat 0x04000000
2024-07-24T18:09:51.877917+00:00 xxxxxxx sshd[3349]: debug1: permanently_set_uid: 105/65534 [preauth]
2024-07-24T18:09:51.877973+00:00 xxxxxxx sshd[3349]: debug1: list_hostkey_types: rsa-sha2-512,rsa-sha2-256,ecdsa-sha2-nistp256,ssh-ed25519 [preauth]
2024-07-24T18:09:51.878017+00:00 xxxxxxx sshd[3349]: debug1: SSH2_MSG_KEXINIT sent [preauth]
2024-07-24T18:09:51.947718+00:00 xxxxxxx sshd[3349]: debug1: SSH2_MSG_KEXINIT received [preauth]
2024-07-24T18:09:51.947838+00:00 xxxxxxx sshd[3349]: debug1: kex: algorithm: [email protected] [preauth]
2024-07-24T18:09:51.947929+00:00 xxxxxxx sshd[3349]: debug1: kex: host key algorithm: ssh-ed25519 [preauth]
2024-07-24T18:09:51.947984+00:00 xxxxxxx sshd[3349]: debug1: kex: client->server cipher: [email protected] MAC: <implicit> compression: none [preauth]
2024-07-24T18:09:51.948032+00:00 xxxxxxx sshd[3349]: debug1: kex: server->client cipher: [email protected] MAC: <implicit> compression: none [preauth]
2024-07-24T18:09:51.948082+00:00 xxxxxxx sshd[3349]: debug1: expecting SSH2_MSG_KEX_ECDH_INIT [preauth]
2024-07-24T18:09:52.033019+00:00 xxxxxxx sshd[3349]: debug1: SSH2_MSG_KEX_ECDH_INIT received [preauth]
2024-07-24T18:09:52.044766+00:00 xxxxxxx sshd[3349]: debug1: ssh_packet_send2_wrapped: resetting send seqnr 3 [preauth]
2024-07-24T18:09:52.044927+00:00 xxxxxxx sshd[3349]: debug1: rekey out after 134217728 blocks [preauth]
2024-07-24T18:09:52.044976+00:00 xxxxxxx sshd[3349]: debug1: SSH2_MSG_NEWKEYS sent [preauth]
2024-07-24T18:09:52.045012+00:00 xxxxxxx sshd[3349]: debug1: Sending SSH2_MSG_EXT_INFO [preauth]
2024-07-24T18:09:52.045047+00:00 xxxxxxx sshd[3349]: debug1: expecting SSH2_MSG_NEWKEYS [preauth]
2024-07-24T18:09:52.145161+00:00 xxxxxxx sshd[3349]: debug1: ssh_packet_read_poll2: resetting read seqnr 3 [preauth]
2024-07-24T18:09:52.145271+00:00 xxxxxxx sshd[3349]: debug1: SSH2_MSG_NEWKEYS received [preauth]
2024-07-24T18:09:52.145321+00:00 xxxxxxx sshd[3349]: debug1: rekey in after 134217728 blocks [preauth]
2024-07-24T18:09:52.145366+00:00 xxxxxxx sshd[3349]: debug1: KEX done [preauth]
2024-07-24T18:09:52.145417+00:00 xxxxxxx sshd[3349]: debug1: SSH2_MSG_EXT_INFO received [preauth]
2024-07-24T18:09:52.145475+00:00 xxxxxxx sshd[3349]: debug1: kex_ext_info_check_ver: [email protected]=<0> [preauth]
2024-07-24T18:09:52.325543+00:00 xxxxxxx sshd[3349]: debug1: userauth-request for user dbrogdon service ssh-connection method none [preauth]
2024-07-24T18:09:52.325656+00:00 xxxxxxx sshd[3349]: debug1: attempt 0 failures 0 [preauth]
2024-07-24T18:09:52.326541+00:00 xxxxxxx sshd[3349]: debug1: PAM: initializing for "dbrogdon"
2024-07-24T18:09:52.328243+00:00 xxxxxxx sshd[3349]: debug1: PAM: setting PAM_RHOST to "71.205.127.54"
2024-07-24T18:09:52.328320+00:00 xxxxxxx sshd[3349]: debug1: PAM: setting PAM_TTY to "ssh"
2024-07-24T18:09:52.328369+00:00 xxxxxxx sshd[3349]: debug1: kex_server_update_ext_info: Sending SSH2_MSG_EXT_INFO [preauth]
2024-07-24T18:09:52.397374+00:00 xxxxxxx sshd[3349]: Connection closed by authenticating user dbrogdon 71.205.127.54 port 52988 [preauth]
2024-07-24T18:09:52.397473+00:00 xxxxxxx sshd[3349]: debug1: do_cleanup [preauth]
2024-07-24T18:09:52.397793+00:00 xxxxxxx sshd[3349]: debug1: monitor_read_log: child log fd closed
2024-07-24T18:09:52.397848+00:00 xxxxxxx sshd[3349]: debug1: do_cleanup
2024-07-24T18:09:52.397924+00:00 xxxxxxx sshd[3349]: debug1: PAM: cleanup
2024-07-24T18:09:52.398518+00:00 xxxxxxx sshd[3349]: debug1: Killing privsep child 3350
2024-07-24T18:09:52.398567+00:00 xxxxxxx sshd[3349]: debug1: audit_event: unhandled event 12

Aqui está o comando que estou usando para conectar:

ssh -v -o PubkeyAuthentication=no -i ./dbrogdon-key.pem [email protected]

Há algo que perdi ao configurar este usuário? Nunca tive esse problema antes em outros sistemas, então estou me perguntando se não há algo específico do Azure.

ssh
  • 1 1 respostas
  • 191 Views

1 respostas

  • Voted
  1. Best Answer
    Ryan Noblett
    2024-07-25T03:12:20+08:002024-07-25T03:12:20+08:00

    Você não especificou quais opções de linha de comando está usando para se conectar, mas com base no log, parece que você não especificou uma chave para usar na conexão.

    Por exemplo, se sua chave estiver no ~/.sshdiretório, o comando deverá ser parecido com isto:

    ssh -i ~/.ssh/dbrogdon-key.pem [email protected]

    Você também pode usar um agente ssh para carregar chaves e usá-las como alternativa, mas não especificou que carregou sua chave em um agente. Os agentes são convenientes se você tiver apenas algumas chaves, mas como os servidores sshd geralmente não aceitam mais de 5 tentativas de autenticação, isso rapidamente se torna insustentável em escala e você precisa especificar as chaves manualmente como acima.


    De acordo com o comando atualizado em sua pergunta, você está especificando explicitamente PubKeyAuthentication=no, o que desabilitaria a autenticação de chave pública que você está usando. PubKeyAuthentication=yesé necessário para que a autenticação de chave pública funcione e é a configuração padrão, portanto normalmente não precisaria ser especificado.

    • 3

relate perguntas

Sidebar

Stats

  • Perguntas 205573
  • respostas 270741
  • best respostas 135370
  • utilizador 68524
  • Highest score
  • respostas
  • Marko Smith

    Você pode passar usuário/passar para autenticação básica HTTP em parâmetros de URL?

    • 5 respostas
  • Marko Smith

    Ping uma porta específica

    • 18 respostas
  • Marko Smith

    Verifique se a porta está aberta ou fechada em um servidor Linux?

    • 7 respostas
  • Marko Smith

    Como automatizar o login SSH com senha?

    • 10 respostas
  • Marko Smith

    Como posso dizer ao Git para Windows onde encontrar minha chave RSA privada?

    • 30 respostas
  • Marko Smith

    Qual é o nome de usuário/senha de superusuário padrão para postgres após uma nova instalação?

    • 5 respostas
  • Marko Smith

    Qual porta o SFTP usa?

    • 6 respostas
  • Marko Smith

    Linha de comando para listar usuários em um grupo do Windows Active Directory?

    • 9 respostas
  • Marko Smith

    O que é um arquivo Pem e como ele difere de outros formatos de arquivo de chave gerada pelo OpenSSL?

    • 3 respostas
  • Marko Smith

    Como determinar se uma variável bash está vazia?

    • 15 respostas
  • Martin Hope
    Davie Ping uma porta específica 2009-10-09 01:57:50 +0800 CST
  • Martin Hope
    kernel O scp pode copiar diretórios recursivamente? 2011-04-29 20:24:45 +0800 CST
  • Martin Hope
    Robert ssh retorna "Proprietário incorreto ou permissões em ~/.ssh/config" 2011-03-30 10:15:48 +0800 CST
  • Martin Hope
    Eonil Como automatizar o login SSH com senha? 2011-03-02 03:07:12 +0800 CST
  • Martin Hope
    gunwin Como lidar com um servidor comprometido? 2011-01-03 13:31:27 +0800 CST
  • Martin Hope
    Tom Feiner Como posso classificar a saída du -h por tamanho 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich O que é um arquivo Pem e como ele difere de outros formatos de arquivo de chave gerada pelo OpenSSL? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent Como determinar se uma variável bash está vazia? 2009-05-13 09:54:48 +0800 CST

Hot tag

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • Início
  • Perguntas
    • Recentes
    • Highest score
  • tag
  • help

Footer

AskOverflow.Dev

About Us

  • About Us
  • Contact Us

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve