Linux에서 SSH 비밀번호 없는 로그인 설정

Linux에서 SSH 비밀번호 없는 로그인 설정

다음 URL의 튜토리얼에 제공된 단계를 사용하여 비밀번호 없이 원격 서버에 로그인하도록 SSH를 설정했습니다. SSH 비밀번호 없는 로그인.

ssh 명령만 사용하여 서버에 로그인하려고 하면 다음과 같습니다.

$ ssh [email protected]

잘 작동하고 비밀번호를 입력하지 않고도 로그인할 수 있지만 scp 명령을 사용하여 로컬에서 원격 서버로 파일을 복사하려고 하면 다음과 같습니다.

$ scp /location/to/file/localserver user@server:location/whereto/copy

비밀번호를 물어보는데 이상해요!

또한 위의 URL에 설명된 대로 모든 폴더에 올바른 권한이 있는지 확인했습니다.

이 문제를 해결하는 방법을 아는 사람이 있나요?

Executing: program /usr/bin/ssh host *.*.*.*, user ssadmin, command scp -v -t /home/ssadmin/nexthink_log`

OpenSSH_6.6.1, OpenSSL 1.0.1e-fips 11 Feb 2013`
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 56: Applying options for *
debug1: Connecting to *.*.*.* [*.*.*.*] port 22.
debug1: Connection established.
debug1: permanently_set_uid: 0/0
debug1: identity file /root/.ssh/id_rsa type -1
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_ed25519 type -1
debug1: identity file /root/.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.6.1
debug1: Remote protocol version 2.0, remote software version OpenSSH_4.3
debug1: match: OpenSSH_4.3 pat OpenSSH_4* compat 0x00000000
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5 none
debug1: kex: client->server aes128-ctr hmac-md5 none
debug1: kex: diffie-hellman-group-exchange-sha1 need=16 dh_need=16
debug1: kex: diffie-hellman-group-exchange-sha1 need=16 dh_need=16
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<3072<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Server host key: RSA **:**:**:**:**:**:**:**:**:**:**:**:**:**
debug1: Host '*.*.*.*' is known and matches the RSA host key.
debug1: Found key in /root/.ssh/known_hosts:1
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,gssapi-with-mic,password
debug1: Next authentication method: gssapi-with-mic
debug1: Unspecified GSS failure.  Minor code may provide more information
No Kerberos credentials available (default cache: KEYRING:persistent:0)
debug1: Unspecified GSS failure.  Minor code may provide more information
No Kerberos credentials available (default cache: KEYRING:persistent:0)
debug1: Next authentication method: publickey
debug1: Trying private key: /root/.ssh/id_rsa
debug1: Trying private key: /root/.ssh/id_dsa
debug1: Trying private key: /root/.ssh/id_ecdsa
debug1: Trying private key: /root/.ssh/id_ed25519
debug1: Next authentication method: password

ssadmin@*.*.*.*'s password:

답변1

먼저 Linux 컴퓨터에 로그인하고 다음 명령을 사용하여 공개 키 쌍을 생성하십시오.

$ ssh-keygen -t rsa

비밀번호를 묻는 메시지가 나타나면 Enter 키를 누르세요.

서버 사용자에 .ssh 폴더를 만들고 새로 생성된 공개 키(id_rsa.pub)를 파일 이름이authorized_keys로 PC에 있는 사용자의 .ssh 디렉터리에 업로드합니다.

권한 설정:

$ ssh [email protected] "chmod 700 .ssh; chmod 640 .ssh/authorized_keys" 

그게 다야!

비밀번호 없는 로그인을 안전하게 보호하세요.

답변2

ssh-copy-id다음 명령을 사용할 수 있습니다.

$ ssh-copy-id 사용자@호스트 이름

authorized_keys그러면 원격 서버의 파일 에만 로컬 키가 추가됩니다 . sshd_config파일에서 인증 키를 활성화하여 사용할 수 있는지 확인하세요 . 이렇게 하면 in ssh이든 out이든 비밀번호를 입력하라는 메시지가 표시되지 않습니다 scp.

답변3

비밀번호를 입력하면 보안 사본이 작동하나요?

권한이 거부된 경우 복사하려는 위치가 원격 사용자의 쓰기를 허용하지 않기 때문일 수 있습니다.

관련 정보