Question

Add ssh-user to the super doers (root privilege) Copy Mac232 directory located in /root and all...

  1. Add ssh-user to the super doers (root privilege)
  1. Copy Mac232 directory located in /root and all its contents to ssh-user home directory

(Hint: use the option –R with cp command to recursively copy the directory’s contents)

Logout then login as ssh-user

- You will need to use the sudo command

  1. Change the ownership of MAC232 directory and all its contents to have the owner of “ssh-user”

(Hint: use the option –R with chown command to recursively change the ownership of the directory’s contents)

  1. Change the permissions of the following directories to read, write and execute by the user, group and other.

~/Mac232

~/Mac232/projects

~/Mac232/projects/labs

Homework Answers

Answer #1

After logging in  from a remote host as the opc user, you can add users on your instance.

  1. Generate an SSH key pair for the new user. In case you don't know follw the steps below to generate them.
  2. Copy the public key value to a text file. You’ll use this key later in this procedure.
  3. Log in to your instance.
  4. Become the root user.

    sudo su

  5. Create the new user:

    useradd new_user (Here you can give any name like ssh-user )

  6. Create a .ssh directory in the new user’s home directory.

    mkdir /home/new_user/.ssh

  7. Copy the SSH public key that you noted earlier to the /home/new_user/.ssh/authorized_keys file.

    echo "key" > /home/new_user/.ssh/authorized_keys

    Here, key is the SSH public key value from the key pair that you generated earlier, enclosed in double quotation marks.

  8. Add the new user to the list of allowed users in the /etc/ssh/sshd_config file on your instance, by editing the AllowUsers parameter, as shown in the following example:

    AllowUsers opc myadmin

    In this scenario , the AllowUsers parameter already had the opc user. The myadmin user has now been added.

  9. Change the owner and group of the /home/username/.ssh directory to the new user:

    chown -R new_user:group /home/new_user/.ssh

  10. Restart the SSH daemon on your instance.

    /sbin/service sshd restart

  11. To enable sudo privileges for the new user, edit the /etc/sudoers file by running the visudo command.In /etc/sudoers, look for the following line:

    %opc ALL=(ALL) NOPASSWD: ALL

    Add the following line right after the preceding line:

    %group_of_new_user ALL=(ALL) NOPASSWD: ALL

You can now log in as the new user:

ssh new_user@ip_address -i private_key

In this command, ip_address is the public IP address of the instance, and private_key is the full path and name of the file that contains the private key corresponding to the public key that you added to the authorized_keys file earlier in this procedure.

Use the following procedure to generate an SSH key pair on UNIX and UNIX-like systems:

1. Run the ssh-keygen command.

You can use the -t option to specify the type of key to create.

For example, to create an RSA key, run:

Copyssh-keygen -t rsa

You can use the -b option to specify the length (bit size) of the key, as shown in the following example:

Copyssh-keygen -b 2048 -t rsa

2. The command prompts you to enter the path to the file in which you want to save the key.

A default path and file name are suggested in parentheses. For example: /home/user_name/.ssh/id_rsa. To accept the default path and file name, press Enter. Otherwise, enter the required path and file name, and then press Enter.

3. The command prompts you to enter a passphrase.

The passphrase is not mandatory if you want to log in to an instance created using an Oracle-provided image. However, it is recommended that you specify a passphrase to protect your private key against unauthorized use.

4. When prompted, enter the passphrase again to confirm it.

The command generates an SSH key pair consisting of a public key and a private key, and saves them in the specified path. The file name of the public key is created automatically by appending .pub to the name of the private key file. For example, if the file name of the SSH private key is id_rsa, the file name of the public key would be id_rsa.pub.

Make a note of the path and file names of the private and public keys. When you create an instance, you must specify the SSH public key value. When you log in to an instance, you must provide the path to the corresponding SSH private key and you must enter the passphrase when prompted.

Use the sudo command to copy Mac232 directory to ssh -user home drectory(It is assumed you already created Mac232 direcctory and its subdirectories projects and Labs. In case not you need to make it using mkdir command)

sudo cp -R /path/to/files/you/want/copied/ /copy/to/this/path/

(the -R is just there to recursively copy directories)

You are now logged in as the new user

Command for changing the ownership of Mac232 directory

sudo  chown -R new_user Mac232

To give permissions on the directories and subdirectories the commands are

su Chmod 777 /Mac232

su Chmod 777 /Mac232/projects

su Chmod 777 /Mac232/projects/labs

The following information about the command is appended herewith. You can modify it according to your need.

7 = Read + Write + Execute
6 = Read + Write
5 = Read + Execute
4 = Read
3 = Write + Execute
2 = Write
1 = Execute
0 = All access denied

First number is for the owner, second for the group, and third for everyone.

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT