Reputation: 2945
Before asking this question, I have searched other solutions and done the following things:
ssh-keygen -t rsa
and cat ~/.ssh/id_rsaK.pub >> ~/.ssh/authorized_keys
su root
, it prints out "Sorry", so I passwd root
to a non-empty passwordsu root
works, but still need password. I don't want this, I want to log in without type any password(Yes, it is not neat, I will check how to improve this later)ssh root@localhost
fails with the following
ssh root@localhost
Password:
Password:
Password:
root@localhost's password:
Permission denied, please try again.
root@localhost's password:
Received disconnect from ::1 port 22:2: Too many authentication failures
Disconnected from ::1 port 22
Upvotes: 0
Views: 2296
Reputation: 95355
You need to put your public key into root
's authorised keys. Then you should be able to ssh root@localhost
without a password.
For example (make sure root has a password first):
ssh-copy-id root@localhost
# <enter root's password>
ssh root@localhost
# should log in without password
# (unless your private key is password protected, in which case, it will
# still ask for that one)
Keep in mind, some setups of SSH server forbid logging in as root. Check the /etc/ssh/sshd_config
file and make sure PermitRootLogin
is set to yes
. If it's not listed anywhere in the file, just add PermitRootLogin yes
on a line by itself (typically, anywhere in this file will do).
Upvotes: 1