Courses‎ > ‎AP Computer Science‎ > ‎Konstantinovich‎ > ‎notes‎ > ‎

2017-11-16 SSH Keys!

posted Nov 16, 2017, 1:18 PM by Konstantinovich Samuel
SSH keys are used to give you a secure way to access another computer (host) without needing to remember or type your password. After you log in to a linux/mac computer, you can generate a key that will let you log in to OTHER computers without a password. You would generate the key along with a comment like this:
ssh-keygen -t rsa -b 4096 -C "Comment"

Comments are useful if you have multiple computers, you can identify which computer you are using e.g.  -C "stuycsLab"  / -C "macbook"   / -c "DesktopHome"  etc

After creating ssh keys, you can upload them to any linux server that you have SSH access to. This can be conveniently done using the ssh-copy-id tool. Like this:

ssh-copy-id -i ~/.ssh/KEY_NAME user@host

You will then be prompted for your password on that host. After you type in your password you will be able to ssh into the host without using your password. 


The commands I used in class follow this post. They allow me to log into any stuycs lab machine with ssh, FROM any other stuycs lab machine. 

ssh-keygen -t rsa -b 4096 -C "konstans-Laptop"

ssh-copy-id -i ~/.ssh/id_rsa.pub  konstans@marge.stuy.edu

I could also copy it to my digital ocean machine!

ssh-copy-id -i ~/.ssh/id_rsa.pub  konstans@IP_ADDRESS_OF_MY_DO_COMPUTER

I left out the host for security reasons.



Comments