다음 명령을 사용하여 Ubuntu 14.04 시스템에서 ssh와 함께 사용할 키를 생성했습니다.
ssh-keygen -t rsa -b 2048
openssl rsa -in id_rsa -outform pem > pk_rsa.pem
openssl rsa -in pk_rsa.pem -pubout -out my_key.pem
my_key.pem을 로컬 OSX에 복사했습니다. 다음 명령을 사용하여 Ubuntu에 SSH로 접속해 보십시오.
ssh -v -i ./my_key.pem [email protected]
OpenSSH_7.4p1, LibreSSL 2.5.0
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Connecting to 192.168.113.137 [192.168.113.137] port 22.
debug1: Connection established.
debug1: key_load_public: No such file or directory
debug1: identity file ./ubu14.pem type -1
debug1: key_load_public: No such file or directory
debug1: identity file ./ubu14.pem-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_7.4
debug1: Remote protocol version 2.0, remote software version OpenSSH_6.6.1p1 Ubuntu-2ubuntu2.8
debug1: match: OpenSSH_6.6.1p1 Ubuntu-2ubuntu2.8 pat OpenSSH_6.6.1* compat 0x04000000
debug1: Authenticating to 192.168.113.137:22 as 'ubuntu'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: [email protected]
debug1: kex: host key algorithm: ecdsa-sha2-nistp256
debug1: kex: server->client cipher: [email protected] MAC: <implicit> compression: none
debug1: kex: client->server cipher: [email protected] MAC: <implicit> compression: none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ecdsa-sha2-nistp256 SHA256:KDokJiZiQ9ZflT5Jm5B8krQ8XgsEEgUjQjg+h6C4Gqo
debug1: Host '192.168.113.137' is known and matches the ECDSA host key.
debug1: Found key in /Users/macdev/.ssh/known_hosts:11
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: publickey
debug1: Trying private key: ./my_key.pem
Enter passphrase for key './my_key.pem':
debug1: Next authentication method: password
[email protected]'s password:
이 문제를 해결할 방법이 있나요?
답변1
두 가지 다른 기술을 혼동하고 openssh
있습니다 openssl
. 전자 만 필요한 것 같습니다.
SSH 키 쌍을 이미 생성했으므로 SSH를 사용하려는 서버에 공개 키를 복사하기만 하면 됩니다. 올바른 방법은 다음과 같습니다
$ ssh-copy-id username@<server-ip>
바꾸다사용자 이름그리고<서버 IP> 서버의 사용자 및 IP 주소를 사용하십시오.