(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
(Hint: use the option –R with chown command to recursively change the ownership of the directory’s contents)
~/Mac232
~/Mac232/projects
~/Mac232/projects/labs
After logging
in from a remote host as the opc
user, you
can add users on your instance.
root
user.
sudo su
useradd new_user (Here you can give any name like ssh-user )
.ssh
directory in the new user’s
home directory.
mkdir /home/new_user/.ssh
/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.
/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.
/home/username/.ssh
directory to the new
user:
chown -R new_user:group /home/new_user/.ssh
/sbin/service sshd restart
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.
Get Answers For Free
Most questions answered within 1 hours.