What is it? @.@

Here is the place where I record some tactics about wargame, systems, and other security issues.


SSH login without password


  1. [Comment] First, login into your workstation and generate a pair of authentication keys.
  2. [Comment] rsa1 for SSH protocol 1, rsa and dsa for SSH protocol 2
  3. [Comment] In my environment, I choose RSA 2 (rsa).
  4. root@simple-plan:~# ssh-keygen -t rsa (dsa | rsa1)
    Generating public/private rsa key pair.
  5. Enter file in which to save the key (/root/.ssh/id_rsa):
    Created directory '/root/.ssh'.
    Enter passphrase (empty for no passphrase):
    Enter same passphrase again:
    Your identification has been saved in /root/.ssh/id_rsa.
    Your public key has been saved in /root/.ssh/id_rsa.pub.
    The key fingerprint is:
    74:a5:7d:6b:5b:03:98:2f:d3:20:a5:1c:e2:ff:33:18 root@simple-plan
  6. [Comment] Now, check the directory contains the key pairs
  7. root@simple-plan:~# ls /root/.ssh/
    id_dsa  id_dsa.pub  identity  identity.pub  id_rsa  id_rsa.pub
  8. [Comment] Copy the public key to the target server
  9. root@simple-plan:~# scp ~/.ssh/id_rsa.pub target_server:~/.ssh/id_rsa.pub -P target_server_port
  10. [Example]
    root@simple-plan:~# scp ~/.ssh/id_rsa.pub www.example.com:~/.ssh/id_rsa.pub -P 22
  11. [Comment] Login the target server and append the public key into a file named "authorized_keys"
  12. root@www.target.com:~# cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
  13. root@www.target.com:~# chmod 755 ~/.ssh
  14. root@www.target.com:~# chmod 644 ~/.ssh/authorized_keys
  15. [Comment] It's done!
  16. root@simple-plan:~# ssh www.target.com -p 22 (no password needed)
  17. root@www.target.com:~#

No comments:

Post a Comment