SSHから接続できず、ユーザー認証でエラーになってしまいます。
何かわかる方がいらっしゃいましたら、どうか少し教えて頂けないでしょうか。
OSはCentOS 6.2 です。
--------------------------------------------------------------------
■サーバー
--------------------------------------------------------------------
★設定
# vi /etc/ssh/sshd_conf
> Port 22
> Protocol 2
> AllowTcpForwarding yes
> GatewayPorts no
> MaxAuthTries 6
> MaxSessions 10
>
> ServerKeyBits 1024
> StrictModes yes
>
> SyslogFacility AUTHPRIV
> LogLevel DEBUG3
>
> PubkeyAuthentication yes
> PasswordAuthentication no
> PermitEmptyPasswords no
> AuthorizedKeysFile.ssh/authorized_keys
>
> PermitRootLogin without-password
> UsePrivilegeSeparation yes
>
> Subsystemsftp/usr/libexec/openssh/sftp-server
> X11Forwarding no
★鍵を作成
# su user1
$ ssh-keygen -t rsa -b 1024
$ Generating public/private rsa key pair.
$ Enter file in which to save the key (/user1/.ssh/id_rsa):
$ Enter passphrase (empty for no passphrase):
$ Enter same passphrase again:
$ Your identification has been saved in /user1/.ssh/id_rsa.
$ Your public key has been saved in /user1/.ssh/id_rsa.pub.
$ The key fingerprint is:
$ 50:4f:72:d4:0a:d6:d2:24:98:96:7b:xx:xx:xx:xx:xx user1@myhost.com
$ The key's randomart image is:
★鍵の名前を変更
$ cd /home/user1/.ssh/
$ cp id_rsa.pub authorised_keys
$ rm id_rsa.pub
★パーミッション確認
$ drwxr-xr-x.rootroot/etc/ssh
$ -rw-------rootroot/etc/ssh/sshd_conf
$ drwxr-xr-x.user1user1/home/user1
$ drwxr-xr-xuser1user1/home/user1/.ssh
$ -rw-r--r--user1user1/home/user1/.ssh/authorised_keys
★再起動
# service sshd restart
# Stopping sshd: OK ]
# Starting sshd: OK ]
--------------------------------------------------------------------
■クライアント
--------------------------------------------------------------------
Windows7 teraterm
ポート:22
SSHバージョン:SSH2
ユーザー名・パスフレーズを入力し、「RSA/DSA鍵を使う」に上記で作った「id_rsa」プライベート鍵をセット。
エラーメッセージ:「SSH2自動ログインエラー:ユーザー認証が失敗しました」
--------------------------------------------------------------------
■ ログ(/var/log/secure)抜粋
--------------------------------------------------------------------
Aug 6 17:57:26 localhost sshd[21819]: debug1: temporarily_use_uid: 0/0 (e=0/0)
Aug 6 17:57:26 localhost sshd[21819]: debug1: trying public key file /user1/.ssh/authorized_keys
Aug 6 17:57:26 localhost sshd[21819]: debug1: restore_uid: 0/0
Aug 6 17:57:26 localhost sshd[21819]: debug1: temporarily_use_uid: 0/0 (e=0/0)
Aug 6 17:57:26 localhost sshd[21819]: debug1: trying public key file /user1/.ssh/authorized_keys
Aug 6 17:57:26 localhost sshd[21819]: debug1: restore_uid: 0/0
Aug 6 17:57:26 localhost sshd[21819]: Failed publickey for user1 from yyy.yyy.yyy.yyy port 58193 ssh2
Aug 6 17:57:26 localhost sshd[21819]: debug3: mm_answer_keyallowed: key 0x7fc196d47cf0 is not allowed
Aug 6 17:57:26 localhost sshd[21819]: debug3: mm_request_send entering: type 22
Aug 6 17:57:26 localhost sshd[21819]: debug3: mm_request_receive entering
Aug 6 17:57:26 localhost sshd[21820]: debug2: userauth_pubkey: authenticated 0 pkalg ssh-rsa
Aug 6 17:57:26 localhost sshd[21820]: debug3: Wrote 68 bytes for a total of 2633
Aug 6 17:57:26 localhost sshd[21820]: Connection closed by yyy.yyy.yyy.yyy
※yyy.yyy.yyy.yyyは、teratermでアクセスしたIPです。
--------------------------------------------------------------------
■備考
--------------------------------------------------------------------
「nmap localhost」は「22/tcp open ssh」ですが、
グローバルIPで「nmap xxx.xxx.xxx.xxx」すると、22番がリストに出ませんでした。
ルーター、iptables、ともにポートは開けています。
(念のため、「iptables」と「system-config-firewall」は停止しています。)
ログを見ると、sshdまで到達しているように見えるのですが・・・。
No.1ベストアンサー
- 回答日時:
コピペ時のミスでしょうか???
># vi /etc/ssh/sshd_conf
sshd_config
ですよね?
>> AuthorizedKeysFile.ssh/authorized_keys
>$ cp id_rsa.pub authorised_keys
>$ -rw-r--r--user1user1/home/user1/.ssh/authorised_keys
公開鍵ファイルの名前が異なっているようですが、間違いありませんか?
あと、公開鍵ファイルのパーミッションは600かと。
# cpで移すのではなく、cat id_rsa.pub >> authorized_keys で追記にするべき…かと思いますが。
>グローバルIPで「nmap xxx.xxx.xxx.xxx」すると、22番がリストに出ませんでした。
どこから実行したのか…が問題かと。
# まあ、ついでに言うなら22番ポートはやめておいた方がいいです。公開鍵認証とは言え。
ありがとうございます。
すみません、お礼の入力を忘れていました。
また、私の別の質問にも回答してくださいましたね。いつもお世話になっています。
>> AuthorizedKeysFile.ssh/authorized_keys
これでした。「authorised_keys」を作っていました。
お恥ずかしい限りで・・・。
お探しのQ&Aが見つからない時は、教えて!gooで質問しましょう!
似たような質問が見つかりました
- MySQL 参考書に従って入力したつもりでしたが、最後はエラーがでました。 1 2022/09/28 03:45
- その他(データベース) AWSのcloud9で「 ls -l ~/.ssh/」のコマンドで公開鍵、 秘密鍵を知ろうとすると「 1 2023/07/09 02:10
- UNIX・Linux Linux(fedora)でホスト名について 2 2022/06/21 14:24
- UNIX・Linux Ubuntu20.04からUbuntu22.04にバージョンアップする際にssh-rsaが無効になっ 1 2022/11/25 00:08
- オープンソース AWSドメイン名でApacheテスト・ページを表示させる方法を教えて下さい。 1 2023/04/26 15:59
- JavaScript Json のキーと値の出力の違いについて 2 2022/06/14 20:22
- MySQL データベースの複製の仕方(mysql) 2 2023/05/30 18:24
- UNIX・Linux postfix smtpサーバーリレーがTLSハンドシェーク失敗 1 2022/08/15 15:45
- UNIX・Linux リナックスのリモート接続の際に使う sshコマンドについて 1 2022/11/21 19:46
- Google 翻訳 【大至急】Hellotalk公式からメール 2 2022/04/17 17:24
このQ&Aを見た人はこんなQ&Aも見ています
おすすめ情報
このQ&Aを見た人がよく見るQ&A
デイリーランキングこのカテゴリの人気デイリーQ&Aランキング
-
AWSでSSH接続をしたいのですが...
-
SSH + rsyncがダメです
-
sftpのバッチモード(Solaris)
-
Ubuntu20.04からUbuntu22.04に...
-
SSHに繋がらない
-
SSH通信で秘密鍵の読み込みが失敗
-
Cyrus SASL 認証Mechanism につ...
-
認証ありのWebDAVでのアクセス
-
Putty(Windows10)からCentOS7の...
-
SSHで多段接続
-
AWSでサーバを構築してWordpres...
-
Windows7 認証エラー0xC004E00...
-
同一のホスト名で何か問題があ...
-
エラーメールで"too many hops"...
-
ワークグループ設定のPCの名前解決
-
Administratorというアカウント...
-
sambaにWinからアクセスできま...
-
VirtualBoxのGuestマシンのネッ...
-
パスワード設定していないユー...
-
TortoiseSVNでアクセスエラー
マンスリーランキングこのカテゴリの人気マンスリーQ&Aランキング
-
AWSでSSH接続をしたいのですが...
-
sftpのバッチモード(Solaris)
-
SSH + rsyncがダメです
-
sftpのパスワードなしでログイン
-
SSHに繋がらない
-
sshでlogin後、操作中、固まる...
-
AWSでサーバを構築してWordpres...
-
WindowsからRLoginでFreebsdにS...
-
ssh公開鍵認証設定の解除について
-
公開鍵方式のsshでパスワード入...
-
Windows7 認証エラー0xC004E00...
-
sshのセッション数
-
SSH通信で秘密鍵の読み込みが失敗
-
メールサーバのログにConnectio...
-
known_hostsを削除してもエラー...
-
centOS7とteratermで、秘密鍵、...
-
認証が必要なプロキシー経由でyum
-
複数人にSSHの秘密鍵と公開鍵を...
-
RADIUSサーバでのMACアドレス認...
-
PAM認証(pam_cracklib.soで複...
おすすめ情報