Write a Bash script that creates an RSA key pair.Requirements:Name of the created private key must be schoolNumber of bits in the created key to be created 4096The created key must be protected by the passphrase bettyExample:sylvain@ubuntu$ ls1-create_ssh_key_pairsylvain@ubuntu$ ./1-create_ssh_key_pairGenerating public/private rsa key pair.Your identification has been saved in school.Your public key has been saved in school.pub.The key fingerprint is:5d:a8:c1:f5:98:b6:e5:c0:9b:ee:02:c4:d4:01:f3:ba vagrant@ubuntuThe key's randomart image is:+--[ RSA 4096]----+| oo... || .+.o = || o + B + || o. = O || .. S = . || .. . || E. . || .. || .. |+-----------------+sylvain@ubuntu$ ls1-create_ssh_key_pair school school.pubsylvain@ubuntu$
Question
Write a Bash script that creates an RSA key pair.Requirements:Name of the created private key must be schoolNumber of bits in the created key to be created 4096The created key must be protected by the passphrase bettyExample:sylvain@ubuntu ./1-create_ssh_key_pairGenerating public/private rsa key pair.Your identification has been saved in school.Your public key has been saved in school.pub.The key fingerprint is:5d:a8:c1:f5:98:b6:e5:c0:9b:ee:02:c4:d4:01:f3:ba vagrant@ubuntuThe key's randomart image is:+--[ RSA 4096]----+| oo... || .+.o = || o + B + || o. = O || .. S = . || .. . || E. . || .. || .. |+-----------------+sylvain@ubuntu
Solution
Here is a simple Bash script that will create an RSA key pair with the specified requirements:
#!/bin/bash
# Define the name of the private key
private_key="school"
# Define the passphrase
passphrase="betty"
# Generate the RSA key pair
ssh-keygen -t rsa -b 4096 -f $private_key -N $passphrase
Here is a step-by-step explanation of the script:
-
The
#!/bin/bashat the top of the script tells the system that this script should be run with the Bash shell. -
The
private_key="school"line defines a variable calledprivate_keyand sets its value to "school". -
The
passphrase="betty"line defines a variable calledpassphraseand sets its value to "betty". -
The
ssh-keygen -t rsa -b 4096 -f $private_key -N $passphraseline is the command that actually generates the RSA key pair. The-t rsaoption specifies the type of key to create (in this case, RSA), the-b 4096option specifies the number of bits in the key (4096), the-f $private_keyoption specifies the filename of the key (the value of theprivate_keyvariable), and the-N $passphraseoption specifies the passphrase for the key (the value of thepassphrasevariable).
To run this script, save it to a file (for example, 1-create_ssh_key_pair), give it execute permissions (chmod +x 1-create_ssh_key_pair), and then run it (./1-create_ssh_key_pair).
Similar Questions
Which of the following commands can be used to generate an RSA key pair for use with an SSH server on a Linux system?Select one:a.ssh-keygen -t rsab.ssh-keygen -t ecdsac.ssh-keygen -t ed25519d.ssh-keygen -t dsa
Which of the two ssh keys cannot be transferred to anyone?1 point possiblePrivate (file id_rsa)Public (file id_rsa.pub)
Which of the following commands can be used to copy an SSH public key to a remote server, allowing the owner of the corresponding private key to log in without a password?Question 13Answera.ssh-copy-id user@remote_hostb.ssh user@remote_host "echo $(cat ~/.ssh/id_rsa.pub) >> ~/.ssh/authorized_keys"c.scp ~/.ssh/id_rsa.pub user@remote_host:~/.ssh/authorized_keysd.echo "$(cat ~/.ssh/id_rsa.pub)" | ssh user@remote_host "cat >> ~/.ssh/authorized_keys"
ssign and print the roll number, phone number and address of two students having names "Sam" and "John" respectively by creating two objects of the class 'Student'.
Which of the following commands can be used to verify the authenticity of an SSH public key, ensuring that it belongs to the expected user?Select one:a.ssh-keygen -lf ~/.ssh/authorized_keysb.ssh-keyscan user@remote_hostc.ssh-keygen -lf ~/.ssh/id_rsa.pubd.ssh-keygen -lf ~/.ssh/known_hosts
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.