태그 보관물: localhost

localhost

암호없이 로컬 호스트에 SSH하는 방법은 무엇입니까? HERE user@PC:~$ ssh-copy-id -i localhost user@localhost’s password: Now try

편집 : 정확히 무슨 일을 넣어.

localhost암호없이 SSH로 연결해야 합니다 (공개 키로)하는 일반적인 방법은 작동하지 않습니다.

user@PC:~$ rm -rf .ssh/*
user@PC:~$ ssh-keygen -t rsa > /dev/null
Enter file in which to save the key (/home/user/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
user@PC:~$ ls .ssh/
id_rsa  id_rsa.pub
user@PC:~$ ssh-copy-id -i localhost
The authenticity of host 'localhost (::1)' can't be established.
RSA key fingerprint is f7:87:b5:4e:31:a1:72:11:8e:5f:d2:61:bd:b3:40:1a.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'localhost' (RSA) to the list of known hosts.
user@localhost's password:
Now try logging into the machine, with "ssh 'localhost'", and check in:

  .ssh/authorized_keys

to make sure we haven't added extra keys that you weren't expecting.

user@PC:~$ ssh-agent $SHELL
user@PC:~$ ssh-add -L
The agent has no identities.
user@PC:~$ ssh-add
Identity added: /home/user/.ssh/id_rsa (/home/user/.ssh/id_rsa)
user@PC:~$ ssh-add -L
ssh-rsa ...MY KEY HERE

user@PC:~$ ssh-copy-id -i localhost
user@localhost's password:
Now try logging into the machine, with "ssh 'localhost'", and check in:

  .ssh/authorized_keys

to make sure we haven't added extra keys that you weren't expecting.

user@PC:~$ ssh localhost echo 'testing'
user@localhost's password:

user@PC:~$

마지막 명령에서 볼 수 있듯이 여전히 암호를 묻습니다. 어떻게 해결할 수 있습니까 ?? 우분투 -10.04, OpenSSH_5.3p1

EDIT2 :

sshd에 대한 정보 추가

user@PC:~$ cat /etc/ssh/sshd_config | grep Authentication
# Authentication:
RSAAuthentication yes
PubkeyAuthentication yes
RhostsRSAAuthentication no
HostbasedAuthentication no
# Uncomment if you don't trust ~/.ssh/known_hosts for RhostsRSAAuthentication
ChallengeResponseAuthentication no
# PasswordAuthentication yes
#KerberosAuthentication no
#GSSAPIAuthentication no
# be allowed through the ChallengeResponseAuthentication and
# PasswordAuthentication.  Depending on your PAM configuration,
# PAM authentication via ChallengeResponseAuthentication may bypass
# PAM authentication, then enable this but set PasswordAuthentication
# and ChallengeResponseAuthentication to 'no'.

EDIT3 : $ ssh -vv localhost의 광고 결과

$ssh -vv localhost
...
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: publickey
debug1: Trying private key: /home/user/.ssh/identity
debug1: Offering public key: /home/user/.ssh/id_rsa
debug2: we sent a publickey packet, wait for reply
debug1: Authentications that can continue: publickey,password
debug1: Trying private key: /home/user/.ssh/id_dsa
debug2: we did not send a packet, disable method
debug1: Next authentication method: password
user@localhost's password:

EDIT4 :

파일이 동일한 지 확인하고 md5sum이 동의하는지



답변

우선, 당신은 당신의 행동을 이해해야합니다 :

user@PC:~$ cat .ssh/id_rsa.pub | ssh localhost 'cat >> .ssh/authorized_keys'

공개 키 .ssh/id_rsa.pub를 ssh를 통해 동일한 호스트 (즉, localhost, 동일한 호스트) 로 복사합니다 . localhost다른 호스트로 교체 하면 더 합리적입니다 (그러나 그것을 수행하는 방법을 배우기 위해 이것을 시도한다면 괜찮습니다).

원격 호스트에 공개 키 사본이 있거나 실제 호스트에있는 공개 키 사본이 있으면 실제 호스트에서 ssh-agent/를 호출하여 인증에 사용해야합니다 ssh-add.

$ eval `ssh-agent`
$ ssh-add

그런 다음 비밀번호 문구를 제공 한 경우에 비밀번호를 입력하라는 메시지가 표시됩니다 ssh-add. 암호없이 개인 키를 생성했다면 그게 전부입니다.


답변

문제를 발견했습니다.

디버깅으로 서버 실행

$sshd -Dd

auth_key를 읽을 수 없다는 것을 알았습니다.

$chmod 750 $HOME

고쳤다.


답변

다음 단계를 수행하십시오

ssh-keygen -t rsa -C "your_email@example.com"
# Creates a new ssh key, using the provided email as a label
# Generating public/private rsa key pair.

기본 파일과 빈 암호를 사용하십시오 (다음 2 단계에서 간단히 Enter 키를 누르십시오).

# start the ssh-agent in the background
eval "$(ssh-agent -s)"
# Agent pid 59566
ssh-add

~ / .ssh / id_rsa.pub의 내용을 ~ / .ssh / authorized_keys에 복사하십시오.

다음 권한이 있는지 확인하십시오

 ls -l .ssh/
 total 20
-rw-r--r--. 1 swati swati  399 May  5 14:53 authorized_keys
-rw-r--r--. 1 swati swati  761 Jan 12 15:59 config
-rw-------. 1 swati swati 1671 Jan 12 15:44 id_rsa
-rw-r--r--. 1 swati swati  399 Jan 12 15:44 id_rsa.pub
-rw-r--r--. 1 swati swati  410 Jan 12 15:46 known_hosts

또한 .ssh 디렉토리에 대한 권한이 있는지 확인하십시오. 이것은 또한 중요하다

drwx------.   2 swati swati    4096 May  5 14:56 .ssh

답변

서버 구성 단순화

암호 기반 인증을 비활성화해야 할 수도 있습니다. 이것은 내가 사용하는 sshd_config입니다

Port 22
Protocol 2
PermitRootLogin no
StrictModes yes
PasswordAuthentication no
ChallengeResponseAuthentication no
MaxStartups 2
AllowUsers peter paul mary
LogLevel VERBOSE

최소한의 것을 먼저 시도한 다음 추가 기능이 필요할 때 추가하십시오.


최신 정보:

서버 로그 확인

EDIT3에서 클라이언트가 암호 기반 인증을 시도하기 전에 공개 키 인증이 실패한 것으로 나타났습니다. 서버의 syslog에 sshd의 메시지가 포함될 수 있습니다.

변경된 구성 재로드

sshd구성 변경 사항을 다시로드 하라는 신호 를 보내십시오. 예 :kill -HUP $(cat /etc/sshd.pid)


답변

위의 게시물과 관련하여 동일한 문제에 직면하면서 방금 줄을 변경했습니다.

비밀번호 인증 번호

/ etc / ssh / sshd_config 파일에서 작동했습니다.

또한 아마도 사용하는 것이 좋습니다

서비스 sshd 다시 시작

sshd 구성 변경 사항을 다시로드하십시오.


답변

sshd가 $ HOME / .ssh를 읽지 못하게하는 Red Hat Enterprise Linux 6.5 SELinux 기능에 대한 또 다른 솔루션은 restorecon을 사용하는 것 입니다. /superuser//a/764020/213743에서 내 답변을 참조 하십시오 .


답변

나를 위해 그것은 간단했다

cat id_rsa.pub >> authorized_keys