In addition you need to bring to class on a USB drive a copy of the private key file generated during the install process (i.e., sa-yourfirstname.pem). This file will be used by me to access your server. We are not turning in the file electronically for security reasons.
->
EC2 ->
Launch Instance
To connect: start putty, enter IP number of your server, go to
Connection ->
SSH ->
Auth and browse for private key
file (choose new ppk file), save the session configuration under a
useful name, connect, username is ubuntu.
chmod 400 /path/to/sa-yourfirstname.pem ssh -i /path/to/sa-yourfirstname.pem ubuntu@your-ip-address
$ ls /root ls: cannot open directory '/root': Permission deniedThe request to list files in the /root directory fails because we don't have permission to look in that directory.
$ sudo ls /root # contents of /root are displayedThis request succeeds because we requested special permissions. Why not just give these accounts full root access so you don't have to type sudo in front of every privileged command? Primarily to keep you from accidently shooting yourself in the foot. Doing everything with root access is like carrying around a loaded gun in your hand!
If you are needing to do a number of system admin tasks and don't want to be bothered with typing sudo in front of everything you can do this:
$ sudo suThen you'll have root privileges with every command. Use CTRL-D or type exit to revert back to normal privileges.
If the upgrade requires a reboot of the system it will create a file named: /var/run/reboot-required. If the file exists you should reboot. Otherwise, a reboot is not needed. Although it is possible to reboot from the command-line I've, in the past, had some strange behavior with AWS servers that are rebooted in this way. So, even though it is more work I always reboot from the AWS console by clicking on the EC2 instances and choosing Actions -> Instance State -> Reboot.
sudo systemctl [command service]
If the command and service are omitted, it will display the state of all background services. Some examples of systemctl commands you will use below with the AppArmor service:
sudo systemctl status apparmor # view status of the apparmor service sudo systemctl start apparmor # start the apparmor service sudo systemctl enable apparmor # cause apparmor service to start on boot
By default AWS Ubuntu 18.04 installs:
https://medium.com/information-and-technology/so-what-is-apparmor-64d7ae211ed
https://medium.com/@jasonrigden/a-guide-to-the-uncomplicated-firewall-ufw-for-linux-570c3774d7f4
IMPORTANT: This is an easy place to shoot yourself in the foot. If you turn on ufw but fail to allow OpenSSH access you will no longer be able to access your server! It is important to test your settings by:
To view/edit your security group go to the EC2 Dashboard, click to see running instances. Click checkbox beside your instance scroll down to see Security groups: launch-wizard-1. Click the link to see Security group details, click on inbound rules. Modify ssh to only allow access from IP numbers you expect to work from. NOTE: One good way to learn your public IP is to visit google.com in your browser and type “what is my ip”. Include in your list of rules the HSU subnet: 209.165.224.0/24
Create a non-privileged account for yourself that allows sudo and use that account to complete the installation.It is conventional to create a non-privileged account that you use to work in the system. Amazon automatically creates such an account for you (called ubuntu). If you want to create your own account, say fred, this is how you would set it up.
sudo cp -rp /home/ubuntu /home/fred sudo chown fred.fred -R /home/fred
Now you should be able to login as fred with the same privileges as ubuntu.
To get the new user account to use the bash shell you may need to edit the appropriate entry in /etc/passwd accordingly.