ssh : 호스트 'hostname'의 신뢰성을 설정할 수 없습니다
컴퓨터에 ssh 할 때 언젠가이 오류 경고가 표시되고 "yes"또는 "no"라는 메시지가 표시됩니다. 다른 컴퓨터로 자동 ssh하는 스크립트에서 실행할 때 약간의 문제가 발생합니다.
경고 메시지 :
The authenticity of host '<host>' can't be established.
ECDSA key fingerprint is SHA256:TER0dEslggzS/BROmiE/s70WqcYy6bk52fs+MLTIptM.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'pc' (ECDSA) to the list of known hosts.
자동으로 "예"라고 말하거나 무시하는 방법이 있습니까?
ssh 클라이언트에 따라 명령 행에서 StrictHostKeyChecking 옵션을 no로 설정하거나 키를 null known_hosts 파일로 보낼 수 있습니다. 구성 파일에서 모든 호스트 또는 지정된 IP 주소 또는 호스트 이름 세트에 대해 이러한 옵션을 설정할 수도 있습니다.
ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no
편집하다
@IanDunn이 지적한 것처럼이 작업을 수행하면 보안 위험이 있습니다. 연결하려는 리소스가 공격자에 의해 스푸핑 된 경우 대상 서버의 챌린지를 잠재적으로 다시 재생하여 원격 리소스에 연결하는 동안 실제로는 해당 리소스에 연결되어 있다고 생각할 수 있습니다. 당신의 자격 증명. HostKeyChecking을 건너 뛰도록 연결 메커니즘을 변경하기 전에 해당 위험이 적절한 지 신중하게 고려해야합니다.
참조 .
더 나은 답변이 필요한 오래된 질문.
비활성화하지 않고 대화식 프롬프트를 방지 할 수 있습니다 StrictHostKeyChecking
(안전하지 않음).
다음 로직을 스크립트에 통합하십시오.
if [ -z `ssh-keygen -F $IP` ]; then
ssh-keyscan -H $IP >> ~/.ssh/known_hosts
fi
서버의 공개 키가에 있는지 확인합니다 known_hosts
. 그렇지 않은 경우 서버에서 공개 키를 요청하여에 추가합니다 known_hosts
.
이러한 방식으로 다음과 같이 완화 할 수있는 Man-In-The-Middle 공격에 한 번만 노출됩니다.
- 스크립트가 보안 채널을 통해 처음 연결되도록 보장
- 로그 또는 known_hosts를 검사하여 지문을 수동으로 확인 (한 번만 수행)
비활성화하거나 제어 비활성화하려면 다음 줄을 시작 부분에 추가하십시오 /etc/ssh/ssh_config
.
Host 192.168.0.*
StrictHostKeyChecking=no
UserKnownHostsFile=/dev/null
옵션 :
- 호스트 서브넷은
*
모든 IP에 대한 무제한 액세스를 허용 할 수 있습니다 . /etc/ssh/ssh_config
글로벌 구성 또는~/.ssh/config
사용자 별 구성을 위해 편집하십시오 .
http://linuxcommando.blogspot.com/2008/10/how-to-disable-ssh-host-key-checking.html을 참조 하십시오
superuser.com과 비슷한 질문-https://superuser.com/a/628801/55163 참조
~/.ssh/known_hosts
쓰기 가능한지 확인하십시오 . 그것은 나를 위해 그것을 고쳤다.
이를 해결하는 가장 좋은 방법은 'StrictHostKeyChecking'외에도 'BatchMode'를 사용하는 것입니다. 이런 식으로 스크립트는 새 호스트 이름을 받아 known_hosts 파일에 쓰지만 예 / 아니오 개입이 필요하지 않습니다.
ssh -o BatchMode=yes -o StrictHostKeyChecking=no user@server.example.com "uptime"
일반적으로 '~ / .ssh / config'에있는 구성 파일을 편집하고 파일을 시작하면 아래 줄을 추가하십시오.
Host *
User your_login_user
StrictHostKeyChecking no
IdentityFile ~/my_path/id_rsa.pub
사용자 your_login_user
가이 설정이 your_login_user
StrictHostKeyCheck에 속 한다고 설정하면 no로 설정하면
IdentityFile이 RSA 키 경로 라는 메시지가 표시되지 않습니다.
이것은 나와 내 스크립트에 도움이됩니다. 행운을 빕니다.
이 경고는 보안 기능으로 인해 발생하므로이 기능을 비활성화하지 마십시오.
한 번만 표시됩니다.
두 번째 연결 후에도 여전히 나타나면 known_hosts
파일 에 문제가있을 수 있습니다. 이 경우 다음과 같은 메시지가 나타납니다.
Failed to add the host to the list of known hosts
파일의 사용 권한을 사용자가 쓸 수 있도록 변경하는 소유자를 변경하여 문제를 해결할 수 있습니다.
sudo chown -v $USER ~/.ssh/known_hosts
Cori의 답변을 참조하여 수정하고 아래 명령을 사용했습니다. 없이는 exit
나머지 명령이 실제로 원격 컴퓨터에 로깅되어 스크립트에서 원하지 않았습니다.
ssh -o StrictHostKeyChecking=no user@ip_of_remote_machine "exit"
이렇게하십시오-> chmod +w ~/.ssh/known_hosts
. 에 파일에 대한 쓰기 권한이 추가됩니다 ~/.ssh/known_hosts
. 그 후 known_hosts
다음에 연결할 때 원격 호스트가 파일에 추가됩니다 .
Generally this problem occurs when you are modifying the keys very oftenly. Based on the server it might take some time to update the new key that you have generated and pasted in the server. So after generating the key and pasting in the server, wait for 3 to 4 hours and then try. The problem should be solved. It happened with me.
Ideally, you should create a self-managed certificate authority. Start with generating a key pair: ssh-keygen -f cert_signer
Then sign each server's public host key: ssh-keygen -s cert_signer -I cert_signer -h -n www.example.com -V +52w /etc/ssh/ssh_host_rsa_key.pub
This generates a signed public host key: /etc/ssh/ssh_host_rsa_key-cert.pub
In /etc/ssh/sshd_config
, point the HostCertificate
to this file: HostCertificate /etc/ssh/ssh_host_rsa_key-cert.pub
Restart the sshd service: service sshd restart
Then on the SSH client, add the following to ~/.ssh/known_hosts
: @cert-authority *.example.com ssh-rsa AAAAB3Nz...cYwy+1Y2u/
The above contains:
@cert-authority
- The domain
*.example.com
- The full contents of the public key
cert_signer.pub
The cert_signer
public key will trust any server whose public host key is signed by the cert_signer
private key.
Although this requires a one-time configuration on the client side, you can trust multiple servers, including those that haven't been provisioned yet (as long as you sign each server, that is).
For more details, see this wiki page.
Add these to your /etc/ssh/ssh_config
Host *
UserKnownHostsFile=/dev/null
StrictHostKeyChecking=no
Run this in host server it's premonition issue
chmod -R 700 ~/.ssh
I had the same error and wanted to draw attention to the fact that - as it just happened to me - you might just have wrong privileges.
You've set up your .ssh
directory as either regular or root
user and thus you need to be the correct user. When this error appeared, I was root
but I configured .ssh
as regular user. Exiting root
fixed it.
I solve the issue which gives below written error:
Error:
The authenticity of host 'XXX.XXX.XXX' can't be established.
RSA key fingerprint is 09:6c:ef:cd:55:c4:4f:ss:5a:88:46:0a:a9:27:83:89.
Solution:
1. install any openSSH tool.
2. run command ssh
3. it will ask for do u add this host like. accept YES.
4. This host will add in the known host list.
5. Now you are able to connect with this host.
This solution is working now......
'Programming' 카테고리의 다른 글
z / OS의 C ++에서 C 소켓 API를 사용하는 방법 (0) | 2020.06.16 |
---|---|
G ++를 사용하여 여러 .cpp 및 .h 파일 컴파일 (0) | 2020.06.15 |
루비 보내기 대 __send__ (0) | 2020.06.15 |
PHP에 배열 키가 있는지 확인하는 것이 더 빠르고 더 좋은 방법은 무엇입니까? (0) | 2020.06.15 |
Intellij에서 다른 하위 버전 분기로 전환하려면 어떻게합니까? (0) | 2020.06.15 |