0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

OpenWrt の ssh パスワードなし rootログイン 鍵の置き場所

Posted at

ローカルユーザ直下に ~/.ssh/id_rsa に鍵があり
OpenWrtサーバーにrootパスワードありログインしている環境を例にします。

#ターミナルから ssh-agent を起動

$ ssh-agent $SHELL

$SHELL は何者かと・・・ echo $SHELL すれば /bin/bash であり、シェル指定ですね。

#ssh-copy-id コマンドで鍵をログイン先にコピー

$ ssh-copy-id  -i ~/.ssh/id_rsa.pub root@192.168.0.38

途中でパスワードを聞かれます

/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "~/.ssh/id_rsa.pub"
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys

root@192.168.0.38's password:       <=ここでログインパスワードを入力します

Number of key(s) added:        1     <=転送されました

Now try logging into the machine, with:   "ssh 'root@192.168.0.38'"
and check to make sure that only the key(s) you wanted were added.

###/root/.ssh/authorized_keys にコピーされました・・・これでもログイン時にパスワードを求められます

root@OpenWrt:~# ls -al /root/.ssh/authorized_keys 
-rw-------    1 root     root          /root/.ssh/authorized_keys

/etc/dropbear 下にコピーするとOK

root@OpenWrt:~# cp /root/.ssh/authorized_keys /etc/dropbear/authorized_keys

これでパスワードなしログインできるようになります。

ssh-agent 参考

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?