Password for ec2-user on AWS Cloud9 - amazon-web-services

I am trying to run $ sudo su in the terminal of AWS Cloud9. I get prompted for the password for the ec2-user. Any ideas what this might be?
Might be worth noting that prior to coming up against this issue, when trying to yum install a package, I got 'packages excluded due to repository priority protections' so I ran yum erase yum-plugin-priorities as per https://serverfault.com/questions/312472/what-does-that-mean-packages-excluded-due-to-repository-priority-protections (I'm fairly sure I had to do that with sudo but wasn't prompted for the password).

First you need to set your password using command
$ sudo passwd ec2-user
Then you can use the new password where ever its required

I ran into the same problem which trying to install homebrew on my ec2#Cloud9 Env.
When requested for password, I didn't place any let the program wait for a while after which I could see the package homebrew got installed.

In the cloud9 (terminal) you have to change the users password with:
$ sudo passwd ec2-user
Changing password for user ec2-user.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.

Use "sudo passwd root" or "sudo passwd"

Related

How to install AWS CLI for root user on Centos 7 - /usr/local/bin not in PATH for root user

When I install the AWS CLI for the root user on CENTOS 7, it installs it to /usr/local/bin as with other users. Problem is though, /usr/local/bin isn't in $PATH for the root user. At first I thought this was a bug in CENTOS, one that has been around for a very long time, but it's also possible its for reasons of security, I don't know.
What would be best practice then to install the AWS CLI for the root user?
To complement Chris'es answer, you can install the AWS CLI v2 in a folder visible to root, such as /usr/local/sbin as follows:
sudo yum install unzip
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install --bin-dir /usr/local/sbin
then confirm with:
aws --version
which should produce:
aws-cli/2.0.44 Python/3.7.3 Linux/3.10.0-1127.el7.x86_64 exe/x86_64.centos.7
This appears to a bug logged in CentOS since 2012 in CentOS 6 but as of yet has not been fixed.
Regarding running AWS CLI as root, you can still run it by running /usr/local/bin/aws although I get that this is not ideal. Additionally you should try to avoid running AWS CLI as root if possible, instead run it as a named user.
According to the documentation you can use either --bin-dir or -b to specify a different bin directory so you could check a path that both root and named users have in their $PATH variable.
What worked for me was
sudo ./aws/install --bin-dir /usr/bin

Creating User For Postgresql

When I enter su postgres it is asking for a password and I did not set any prior password.
I am using a Django book and have installed PostgreSQL with sudo apt-get install PostgreSQL PostgreSQL-contrib I installed it within a virtual environment the instructions are vague on where to install so I just install it in there. Also installed the install the psycopg2 PostgreSQL adapter for Python with
pip install psycopg2-binary==2.8.4. I am now in the next step to create a user for the PostgreSQL but can't pass that step the instructions provided are to enter su postgres and immediately after createuser -dp user-name and it is asking for a password. I have entered my superuser password but showing authentication failure.
Thanks
in your linux terminal write the commands
sudo -s
su postgres
psql
then you connect to postgres
to create a user from psql you type
create user username with encrypted password 'password';
to create a database with specific owner you type
create database databasename with encoding 'utf8' owner username;
to exit from psql you type
\q
last but not least to alter the password for user postgres with psql run the command
alter user postgres with encrypted password 'password';
then restart the postgresql server
sudo service postgresql restart

Access denied After MySQL Manual Installation on Google Compute Engine

Somehow I wanted to install MySQL manually, so I did as explained in How to Set Up MySQL on Google Compute Engine except that I didn't need to create a VM instance because I already have one.
That is, since my OS is 'Debian GNU/Linux 9 (stretch)', I executed the following two commands to install MySQL:
$ sudo apt-get update
and
$ sudo apt-get -y install mysql-server
There's no errors in this step and I created a root password by the following command:
$ sudo mysql_secure_installation
But when I tried to connect to MySQL, (entering the root password I created)
$ mysql --user=root --password
I've got
ERROR 1698 (28000): Access denied for user 'root'#'localhost'
What would be a problem here and what should I check in order to connect to MySQL?
There is an error on the tutorial. In order to connect to the MySQL you should run:
$ sudo mysql --user=root --password

How to run commands as root on AWS instances?

I have a AWS instances but I can't login as root, just can login with my account. What are the command I can use to edit root's files?
as said above it is best to use sudo or
$ sudo su root
but, if you really like to login as root, open
$ /etc/ssh/sshd_config
and set PermitRootLogin to true
then you can login to the instance as root.
(also restart ssh daemon, # systemctl reload sshd)
If you need to run a command as root, you must prefix the command with sudo. Like,
sudo <command>
The best way is to use sudo with the user you got, like ec2-user, ubuntu, centos etc.
sudo command_you_would_like_to_run

On creating a new ember app i am getting bower handlebars error

Installed packages for tooling via npm.
EACCES, unlink '/home/tanan/.cache/bower/registry/bower.herokuapp.com/lookup/handlebars_b644d'
Error: EACCES
unlink '/home/tanan/.cache/bower/registry/bower.herokuapp.com/lookup/handlebars_b644d'
Unable to identify this particular error
Also if anybody knows how to install ember-cli as a notmarl user (not a root user)
When you installing did you use 'sudo' or run as the root user? For me the installer failed and I had not choice then I experienced the same issue.
Try and reset the permissions back from root to your user with these commands:
sudo chown -R <you>:staff ~/.cache
sudo chown -R <you>:staff ~/.npm
Assume you are running OS X, modify accordingly.