ssh to remote server without password
- install openssh in both local and remote machine;
- run ssh-keygen in the local machine,you'll get id_rsa and id_rsa.pub;
- well,the file id_rsa stors your private key,you must keep it secret;
- while id_rsa.pub is the public key,just keep it from writing by others.
- deliver id_rsa.pub to the remote server you want to login without password by whatever ways,e.g. scp .ssh/id_rsa.pub user@server:.ssh/ of course you will be prompted for password this time,make sure there is a .ssh directory in the remote server and it's mode is 700
- cat .ssh/id_rsa.pub >> .ssh/authorized_keys (run in remote server)
- chmod 644 .ssh/id_rsa.pub .ssh/authorized_keys (also in remote server)
- now have a try.
note2:if you put your non-root user's public key to /root/.ssh of the remote server,then you can login to remote server as root directory,so either avoid this situation or protect the password of your local account.
3 comments:
竟然不撞墙了。。。
Post a Comment