SSH / sFTP return Connection refused

0

I change the permission with SSH (very simple just "chown -R ec2-user:apache /var/www/html/xxxxx/xxxx/xxx"), the SSH reject my connection and ssh: connect to host xxx.xxx.xxx.xxx port 22: Connection refused... After that I check and reboot the EC2 but not effective...

What can I do...

已提问 1 年前344 查看次数
1 回答
0

In accordance with AWS, Apache httpd serves files that are kept in a directory called the Apache document root. The Amazon Linux Apache document root is /var/www/html, which by default is owned by root. (Your case may be /var/www/html/xxxx/public_html where you have made directory) To allow the ec2-user account to manipulate files in this directory, you must modify the ownership and permissions of the directory. There are a few ways to perform this task. AWS tutorial suggests, you add ec2-user to the apache group, to give apache group ownership of the /var/www directory and assign write permissions to the group.

Add your user (ec2-user) to the apachegroup

$sudo usermod -a -G apache ec2-user

Change the group ownership of /var/www and its contents to the apache group.

$sudo chown -R ec2-user:apache /var/www (Do not forget to add your directories, /var/www/html/xxxxx/xxxx/xxx)

If you are using the SSH client (Linux, Ubuntu) and downloed the file and copied in the Downloaded folder.

$chmod 400 x.pem (x.pem, replace with your pem file)

If your subnet is configured to get public IP automatically, then every reboot you get new IP address and as such your public dns changes.

If you are using EC2 Instance connect, please check your security group.

Please navigate this link:

https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-lamp-amazon-linux-2.html

Please let me know, I am also learning.

已回答 1 年前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则