Issue
Before asking this question, I have searched other solutions and done the following things:
ssh-keygen -t rsa
andcat ~/.ssh/id_rsaK.pub >> ~/.ssh/authorized_keys
- Enable root account on Mac, and set password to empty
su root
, it prints out "Sorry", so Ipasswd root
to a non-empty password- Now
su 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 followingssh 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
Solution
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).
Answered By - dreamlax