ドットインストール(こことここ)を参考に、公開鍵方式でのssh接続を試しています。接続自体は出来るのですが、パスワードを求められます。
MAC ~ % ssh -i ~/.ssh/id_rsa VPSUSER@IP.ADD.RE.SS The authenticity of host 'IP.ADD.RE.SS (IP.ADD.RE.SS)' can't be established. ECDSA key fingerprint is SHA256:Rjz8BLk1~~~~~~~~~~~~~~~中略~~~~~~~~~~~~wFAxk4. Are you sure you want to continue connecting (yes/no/[fingerprint])? yes Warning: Permanently added 'IP.ADD.RE.SS' (ECDSA) to the list of known hosts. VPSUSER@IP.ADD.RE.SS's password: MAC ~ % ssh -i ~/.ssh/id_rsa VPSUSER@IP.ADD.RE.SS VPSUSER@IP.ADD.RE.SS's password:
通常、公開鍵方式での接続の場合は、このようなパスワードは求められないと認識しているのですが、間違いないですよね?。
このあと、パスワードでのログインが出来ないように設定をするつもりですので、何とかしたいと思うのですが、わかる人がいましたらご教授いただければ幸いです。パスフレーズの設定はしていません。
また、Cyberduckでは、SFTPにより、パスワード無しでのログインができました。
検索するとknownhostなるものをいじるとよいと、聞いて、上記のknown_hostsを消してみましたが、症状は改善しませんでした。
他に必要な情報があればおっしゃっていただければと存じます。
下記にサーバー上の公開鍵の権限など
$ pwd /home/VPSUSER $ ls -la drwx------ 2 VPSUSER VPSUSER 4096 5月 8 20:59 .ssh $ ls -la .ssh -rw------- 1 VPSUSER VPSUSER 582 5月 8 20:52 authorized_keys
VPSの環境
Ubuntu 20.04.2 LTS (GNU/Linux 5.4.0-72-generic x86_64)
使用しているPCはmacOS 11.3.1です。
MAC ~ % cat .ssh/known_hosts IP.ADD.RE.SS ecdsa-sha2-nistp256 AAA略
試した事
①PC側で公開鍵の作成
MAC ~ % ssh-keygen -t rsa -v Generating public/private rsa key pair. Enter file in which to save the key (/Users/user/.ssh/id_rsa): //エンターキーのみ Created directory '/Users/user/.ssh'. Enter passphrase (empty for no passphrase): //エンターキーのみ(パスフレーズの設定はしていません) Enter same passphrase again: //エンターキーのみ Your identification has been saved in /Users/user/.ssh/id_rsa. Your public key has been saved in /Users/user/.ssh/id_rsa.pub. The key fingerprint is: SHA256:R5LEAQ9xyd~~~~~~中略~~~~~ user@Macbook-Air.local The key's randomart image is: +---[RSA 3072]----+ | ああ| +----[SHA256]-----+ MAC ~ % chmod 600 .ssh/id_rsa.pub
②VPSサーバー側で公開鍵の受け皿の作成
$ mkdir .ssh $ chmod 700 .ssh
③MAC側で公開鍵のアップロード
MAC ~ % scp ~/.ssh/id_rsa.pub VPSUSER@IP.ADD.RE.SS:~/.ssh/authorized_keys The authenticity of host 'IP.ADD.RE.SS (IP.ADD.RE.SS)' can't be established. ECDSA key fingerprint is SHA256:Rjz8BLk~~~~~~~~~~~~~~~~~~~~~~~~. Are you sure you want to continue connecting (yes/no/[fingerprint])? y Please type 'yes', 'no' or the fingerprint: yes Warning: Permanently added 'IP.ADD.RE.SS' (ECDSA) to the list of known hosts. VPSUSER@IP.ADD.RE.SS's password: scp: /home/VPSUSER/.ssh/authorized_keys: No such file or directory MAC ~ % scp ~/.ssh/id_rsa.pub VPSUSER@IP.ADD.RE.SS:~/.ssh/authorized_keys VPSUSER@IP.ADD.RE.SS's password: id_rsa.pub 100% 582 35.5KB/s 00:00
追記
「Mac ~ % ssh -v VPSUSER@IP.ADD.RE.SS」を実行。
Mac ~ % ssh -v VPSUSER@IP.ADD.RE.SS OpenSSH_8.1p1, LibreSSL 2.7.3 debug1: Reading configuration data /etc/ssh/ssh_config debug1: /etc/ssh/ssh_config line 47: Applying options for * debug1: Connecting to IP.ADD.RE.SS [IP.ADD.RE.SS] port 22. debug1: Connection established. debug1: identity file /Users/user/.ssh/id_rsa type 0 debug1: identity file /Users/user/.ssh/id_rsa-cert type -1 debug1: identity file /Users/user/.ssh/id_dsa type -1 debug1: identity file /Users/user/.ssh/id_dsa-cert type -1 debug1: identity file /Users/user/.ssh/id_ecdsa type -1 debug1: identity file /Users/user/.ssh/id_ecdsa-cert type -1 debug1: identity file /Users/user/.ssh/id_ed25519 type -1 debug1: identity file /Users/user/.ssh/id_ed25519-cert type -1 debug1: identity file /Users/user/.ssh/id_xmss type -1 debug1: identity file /Users/user/.ssh/id_xmss-cert type -1 debug1: Local version string SSH-2.0-OpenSSH_8.1 debug1: Remote protocol version 2.0, remote software version OpenSSH_8.2p1 Ubuntu-4ubuntu0.2 debug1: match: OpenSSH_8.2p1 Ubuntu-4ubuntu0.2 pat OpenSSH* compat 0x04000000 debug1: Authenticating to IP.ADD.RE.SS:22 as 'VPSUSER' debug1: SSH2_MSG_KEXINIT sent debug1: SSH2_MSG_KEXINIT received debug1: kex: algorithm: curve25519-sha256 debug1: kex: host key algorithm: ecdsa-sha2-nistp256 debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none debug1: expecting SSH2_MSG_KEX_ECDH_REPLY debug1: Server host key: ecdsa-sha2-nistp256 SHA256:Rjz8BLk12zzXoBrcG5vZlzT+RWUosls93VYylwFAxk4 debug1: Host 'IP.ADD.RE.SS' is known and matches the ECDSA host key. debug1: Found key in /Users/user/.ssh/known_hosts:1 debug1: rekey out after 134217728 blocks debug1: SSH2_MSG_NEWKEYS sent debug1: expecting SSH2_MSG_NEWKEYS debug1: SSH2_MSG_NEWKEYS received debug1: rekey in after 134217728 blocks debug1: Will attempt key: /Users/user/.ssh/id_rsa RSA SHA256:R5LEAQ9xydhROZe3c9la/qbFxFM1UB0DNJQuv6XTjY8 debug1: Will attempt key: /Users/user/.ssh/id_dsa debug1: Will attempt key: /Users/user/.ssh/id_ecdsa debug1: Will attempt key: /Users/user/.ssh/id_ed25519 debug1: Will attempt key: /Users/user/.ssh/id_xmss debug1: SSH2_MSG_EXT_INFO received debug1: kex_input_ext_info: server-sig-algs=<ssh-ed25519,sk-ssh-ed25519@openssh.com,ssh-rsa,rsa-sha2-256,rsa-sha2-512,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,sk-ecdsa-sha2-nistp256@openssh.com> debug1: SSH2_MSG_SERVICE_ACCEPT received debug1: Authentications that can continue: publickey,password debug1: Next authentication method: publickey debug1: Offering public key: /Users/user/.ssh/id_rsa RSA SHA256:R5LEAQ9xydhROZe3c9la/qbFxFM1UB0DNJQuv6XTjY8 debug1: Authentications that can continue: publickey,password debug1: Trying private key: /Users/user/.ssh/id_dsa debug1: Trying private key: /Users/user/.ssh/id_ecdsa debug1: Trying private key: /Users/user/.ssh/id_ed25519 debug1: Trying private key: /Users/user/.ssh/id_xmss debug1: Next authentication method: password VPSUSER@IP.ADD.RE.SS's password: debug1: Authentication succeeded (password). Authenticated to IP.ADD.RE.SS ([IP.ADD.RE.SS]:22). debug1: channel 0: new [client-session] debug1: Requesting no-more-sessions@openssh.com debug1: Entering interactive session. debug1: pledge: network debug1: client_input_global_request: rtype hostkeys-00@openssh.com want_reply 0 debug1: Remote: Ignored authorized keys: bad ownership or modes for direcuser /home/VPSUSER debug1: Sending environment. debug1: Sending env LANG = ja_JP.UTF-8 Welcome to Ubuntu 20.04.2 LTS (GNU/Linux 5.4.0-72-generic x86_64) * Documentation: https://help.ubuntu.com * Management: https://landscape.canonical.com * Support: https://ubuntu.com/advantage System information as of 2021年 5月 9日 日曜日 09:00:19 JST System load: 0.08 Processes: 107 Usage of /: 27.8% of 29.40GB Users logged in: 0 Memory usage: 39% IPv4 address for eth0: IP.ADD.RE.SS Swap usage: 1% * Pure upstream Kubernetes 1.21, smallest, simplest cluster ops! https://microk8s.io/ Last login: Sat May 8 21:07:14 2021 from 1 $
回答2件
あなたの回答
tips
プレビュー