반응형

출처 : https://www.linuxquestions.org/questions/linux-newbie-8/ssh-login-without-password-not-working-4175561052/

비밀번호가 없는 SSH 로그인이 잘 안됩니다

안녕하세요.

여기에 첫번째 위협입니다만 제가 규칙을 어긴거라면 친절하게 대해주세요... :)

저는 NAS 장치가 있고 2개 장치 모두에 root로 접근합니다.

저는 그들 사이에 rsync를 하고 싶습니다.

rsync 명령은 잘 됩니다만... cron job으로 자동화가 불가능 하도록 만드는 password 구문이 프롬프트로 나타납니다.

저는 이미 rsa key를 생성했고 다른 NAS로 인증 키를 얻었지만, 그 이후에도 password 구문이 있습니다.

다음을 시도하였습니다.

"cat /root/.ssh/id_rsa.pub | ssh root@destinationip 'cat >> .ssh/authorized_keys'

다음처럼 결과가 나왔습니다.

"The authenticity of host 'dest ip (destip)' can't be established.
RSA key fingerprint is 35:60:b9:53:a4:08:fb:1a:be:7a:7d:b5:4f:ee:cc:2c.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'destip' (RSA) to the list of known hosts.
root@destip's password:

누군가 범인이 어디에 있는지 힌트를 줄 수 있습니까?

1개의 답변

부적절한 권한이 주로 이에 대한 원인입니다.

chmod 750 ~
chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys

대상 머신에서 위의 권한 작업을 해야합니다.

반응형
반응형
출처 

http://www.linuxproblem.org/art_9.html

비밀번호 없이 SSH 로그인

목표

당신이 리눅스를 사용하고 당신의 작업을 자동화하기 위해 OpenSSH를 사용하기 원합니다. 그래서 당신은 host A / 사용자 a에서 호스트 B / 사용자 b로 자동 로그인이 필요합니다. 당신은 쉘 스크립트(shell script)로 ssh를 호출하고 싶기 때문에 비밀번호를 입력하길 원하지 않을것입니다.

방법

우선 호스트 A에서 a 사용자로 로그인하여 인증 키 쌍을 생성합니다. passphrase는 입력하지 않습니다.

a@A:~> ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/a/.ssh/id_rsa):
Created directory '/home/a/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/a/.ssh/id_rsa.
Your public key has been saved in /home/a/.ssh/id_rsa.pub.
The key fingerprint is:
3e:4f:05:79:3a:9f:96:7c:3b:ad:e9:58:37:bc:37:e4 a@A


이제 호스트 B에서 b 사용자로 ssh 프로그램을 사용하여 ~/.ssh 디렉터리를 만듭니다. (디렉터리가 이미 있을지 모르지만 괜찮습니다.)

a@A:~> ssh b@B mkdir -p .ssh
b@B's password:


마지막으로 a 사용자의 새로운 공개키를 b@B:.ssh/authorized_keys에 추가하고 마지막으로 b 사용자의 비밀번호를 입력합니다.

a@A:~> cat .ssh/id_rsa.pub | ssh b@B 'cat >> .ssh/authorized_keys'
b@B's password:


이제부터 비밀번호 없이 호스트 B의 b 사용자로 로그인 할 수 있습니다.

a@A:~> ssh b@B


독자중 한명으로부터 당신의 SSH 버젼에 따라 당신은 다음 작업을 해야할 수 있습니다. 

  • .ssh/authorized_keys2에 public key를 넣습니다.
  • .ssh 디렉터리 권한을 700으로 변경(chmod)합니다.
  • .ssh/authorized_keys2의 권한을 640으로 변경합니다.

다음 출처 : https://opentutorials.org/module/432/3742

역자 추가내용 : 호스트 B의 b 사용자는 .ssh 디렉터리에 다음 권한처럼 설정이 필요합니다.

1
2
3
4
5
chmod 700 ~/.ssh
chmod 600 ~/.ssh/id_rsa
chmod 644 ~/.ssh/id_rsa.pub 
chmod 644 ~/.ssh/authorized_keys
chmod 644 ~/.ssh/known_hosts


반응형

+ Recent posts