deeejay

Bash - Create SSH key on remote server

Dec 23rd, 2015
394
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.61 KB | None | 0 0
  1. Generates key on source machine
  2. ===
  3. ssh-keygen -t rsa -C root@source_hostname.domain.org
  4.  
  5. Copies key to target machine
  6. ===
  7. ssh-copy-id root@target_hostname.domain.org
  8.  
  9. SSH into target machine
  10. ===
  11. ssh root@target_hostname.domain.org
  12.  
  13. Copies keys to other servers in cluster
  14. ===
  15. ssh-copy-id root@target2_hostname.domain.org
  16. ssh-copy-id root@target3_hostname.domain.org
  17. ssh-copy-id root@target4_hostname.domain.org
  18.  
  19. Troubleshooting
  20. ===
  21. chmod 777 /root/.ssh - may fix password prompts after copying key to target server
  22. DO NOT chmod g-w /root/.ssh - Jenkins builds will get "Permission Denied" errors and fail
Advertisement
Add Comment
Please, Sign In to add comment