SSH com login automático


/ Published in: Other
Save to your folder(s)



Copy this code and paste it in your HTML
  1. On the client run the following commands:
  2.  
  3. $ mkdir -p $HOME/.ssh
  4. $ chmod 0700 $HOME/.ssh
  5. $ ssh-keygen -t dsa -f $HOME/.ssh/id_dsa -P ''
  6. This should result in two files, $HOME/.ssh/id_dsa (private key) and $HOME/.ssh/id_dsa.pub (public key).
  7. Copy $HOME/.ssh/id_dsa.pub to the server.
  8.  
  9. On the server run the following commands:
  10.  
  11. $ cat id_dsa.pub >> $HOME/.ssh/authorized_keys2
  12. $ chmod 0600 $HOME/.ssh/authorized_keys2
  13. Depending on the version of OpenSSH the following commands may also be required:
  14. $ cat id_dsa.pub >> $HOME/.ssh/authorized_keys
  15. $ chmod 0600 $HOME/.ssh/authorized_keys
  16. An alternative is to create a link from authorized_keys2 to authorized_keys:
  17. $ cd $HOME/.ssh && ln -s authorized_keys2 authorized_keys
  18. On the client test the results by ssh'ing to the server:
  19.  
  20. $ ssh -i $HOME/.ssh/id_dsa server
  21. (Optional) Add the following $HOME/.ssh/config on the client:
  22.  
  23. Host server
  24. IdentityFile ~/.ssh/id_dsa
  25. This allows ssh access to the server without having to specify the path to the id_dsa file as an argument to ssh each time.

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.