Last updated on Sep 7, 2024, 20:11 by mokubo3
To securely connect to the Hills server, it's recommended to use SSH keys. Here's how to generate and use SSH keys on your machine.
Open your terminal and run the following command to generate a new SSH key pair:
ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
- -t rsa
specifies the type of key to create (RSA).
- -b 4096
defines the key length (4096 bits for added security).
- -C
adds a comment to the key, typically your email.
You'll be prompted to choose a file in which to save the key. Press Enter to accept the default location (~/.ssh/id_rsa
):
Enter file in which to save the key (/home/you/.ssh/id_rsa): [Press Enter]
You can set a passphrase for added security. If you don’t want a passphrase, just press Enter:
Enter passphrase (empty for no passphrase): [Press Enter]
To use your SSH key for authentication, add it to the SSH agent:
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_rsa
Use the following command to upload your public key to the Hills server:
ssh-copy-id <username>@hills.ccsf.edu
Replace <username>
with your CCSF username. This will copy your public key to the server, enabling passwordless login.
After uploading the key, you can connect to the server without entering your password:
ssh <username>@hills.ccsf.edu
[~] > ssh-keygen -t rsa -b 4096 -C <username>@mail.ccsf.edu Generating public/private rsa key pair. Enter file in which to save the key (~/.ssh/id_rsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in ~/.ssh/id_rsa Your public key has been saved in ~/.ssh/id_rsa.pub The key fingerprint is: SHA256:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX <username>@mail.ccsf.edu The key's randomart image is: +---[RSA 4096]----+ | | | = | | | | . | | o | | | | + . | | | | . | +----[SHA256]-----+ [~] > eval "$(ssh-agent -s)" Agent pid 12345 [~] > ssh-add ~/.ssh/id_rsa Enter passphrase for ~/.ssh/id_rsa: Identity added: ~/.ssh/id_rsa (<username>@mail.ccsf.edu) [~] > ssh-copy-id <username>@hills.ccsf.edu /usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed /usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys <username>@hills.ccsf.edu's password: Number of key(s) added: 1 Now try logging into the machine, with: "ssh '<username>@hills.ccsf.edu'" and check to make sure that only the key(s) you wanted were added. [~] > ssh <username>@hills.ccsf.edu ********************************************************** * W A R N I N G ! * * * * BY ACCESSING AND USING THIS SYSTEM YOU CONSENT TO * * SYSTEM MONITORING FOR LAW ENFORCEMENT AND OTHER * * PURPOSES. * * * * UNAUTHORIZED USE OF THIS COMPUTER SYSTEM MAY SUBJECT * * YOU TO CRIMINAL PROSECUTION AND PENALTIES. * * * * DO NOT COPY OR INSTALL ANY ILLEGAL OR UNLICENSED * * SOFTWARE ON THIS COMPUTER SYSTEM! * * Refer to CCSF Computer Usage Policy for additional * * information: http://www.ccsf.edu/Policy/NEWpolicy.html * * * * INTERNSHIP INFORMATION is in /pub/cs/internships.txt * * * ********************************************************** Last failed login: Sat Sep 7 17:50:50 PDT 2024 from 255.255.0.0 on ssh:notty There was 1 failed login attempt since the last successful login. Last login: Sat Sep 7 17:26:47 2024 from 255.255.0.0 [<username>@hills ~]$
If you have any questions, please reach out to the CS Tutor Squad.