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年前348ビュー
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年前

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン