permission denied if i want to connect to aws servers - amazon-web-services

I launched two Ubuntu free-tier servers in different regions on AWS. I was ping one server to another server but it displayed one error message that was connection timed out.can you please fix the problem as soon as possible.
This is the error:
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/home/ubuntu/.ssh/id_rsa.pub"
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
Permission denied (publickey).
172.31.94.158 | UNREACHABLE! => {
"changed": false,
"msg": "Failed to connect to the host via ssh: ssh: connect to host 172.31.94.158 port 22: Connection timed out\r\n",
"unreachable": true
}
I tried below commands
1.ssh-copy-id ubuntu#172.31.94.158
2.sudo ansible webserver -m ping

the simplest way would be open port 22 on security group attached to the server for public IP of another server which it wants to connect.
if its simple test server and you want to check ssh connectivity for short duration and willing to delete server as soon as the test is done. then you can open ssh port publicly "highly insecure"

Related

When mounting an S3 bucket on an ubuntu EC2 instance with S3FS, SSH connection is not possible

As stated above, I mounted an S3 bucket with S3FS on an ubuntu instance that I was able to SSH to, and when I restarted the instance, SSH connection to the instance was no longer possible.
ssh command
ssh -i "pem filename" ubuntu#"ec2-domain-name"
Error message
ssh: connect to host "ec2-domain name" port 22: Connection refused
This event did not occur until 2/28/2022, but started to occur on 3/1/2022.
Please let me know if you know the solution or if you have encountered the same issue.

How to connect to remote hashicorp vault server

Let me explain my use-case here,
I wanted to give a try to vault in my local, so I configured VAULT_ADDR as:
$ echo $VAULT_ADDR
http://127.0.0.1:8200
then I started vault in dev mode (vault server -dev) and everything was ok, I was able to connect to the server.
Then I wrote a really simple config file:
$ cat vault.config
backend "inmem" {}
listener "tcp" {
address = "127.0.0.1:8200"
tls_disable = 1
}
disable_mlock = true
and I restarted the server with vault server -config=vault.config, This too worked fine.
Now I want to use vault server which is deployed in remote server (aws ec2 instance). I have changed content my config file to below
backend "inmem" {}
listener "tcp" {
address = "123.456.789.1:8200" (aws ec2 public ip)
tls_disable = 1
}
disable_mlock = true
now this is throwing error
Error checking seal status: Get "http://123.456.789.1:8200/v1/sys/seal-status": dial tcp 123.456.789.1:8200: connect: connection refused'
when i am trying to check connectivity using telnet command, that too failed.
telnet 123.456.789.1 8200
telnet: Unable to connect to remote host: Connection refused
I have opened 8200 port in security group of aws, and both instances are in same vpc. What I am missing here? Any help?
I was able to figure out solution for above issue. Basically I executed below steps.
First I started vault server in above machine ( '123.456.XXX.X' ) by below command
vault server -dev -dev-listen-address="123.456.789.1:8200"
here 123.456.789.1 --> This is private IP of my ec2 instance, where my vault server is running.
Next, In my source machine (the one from which i am invoking vault server in 123.456.XXX.X ), I set below parameters
export VAULT_ADDR='http://123.456.789.1:8200'
export VAULT_TOKEN='*****************'
Now when I am trying to do telnet to 123.456.XXX.X server, it is working as expected
telnet 123.456.789.1 8200
output
Trying 123.456.789.1...
Connected to 123.456.789.1.
Escape character is '^]'.
I had the same problem
I was trying to reach my remote vault server this helps me https://stackoverflow.com/a/67218570/19887897
You just have to start your server like this
vault server -dev  -dev-listen-address="0.0.0.0:8200"

Unable to login GCP Virtual Machine (Reason: failed to connect to backend)

My GPC Linux VM is working fine and one day naturally can't log in, even though it is still running,
I used the nomachine to login and got error "authentication failed, please try again."
when SSH:
Connection via Cloud Identity-Aware Proxy Failed
Code: 4003
Reason: failed to connect to backend
You may be able to connect without using the Cloud Identity-Aware Proxy.
I also try add:
#! /bin/bash
useradd -G sudo USERNAME
echo 'USERNAME:PASSWORD' | chpasswd
and
route add default gw <gateway ip> eth0
I created another virtual machine and its image, but after a day I couldn't connect
Ensure you have a firewall rule to allow Cloud Identity-Aware Proxy (IAP) to connect to port 22 on the instance. Full instructions can be found at [1].
[1] https://cloud.google.com/iap/docs/using-tcp-forwarding?authuser=0#create-firewall-rule
Cause:
When an instance does not have a public IP address, SSH in a Browser needs to forward the SSH connection through IAP. The error "failed to connect to backend" indicates that the IAP proxy service was unable to open a TCP connection to the instance.
This is most often due to the VPC firewall not having a rule which allows the proxy to connect to the instance. It coulld also be due to the OS firewall or other VM network connectivity issue.

how to configure ssh server on jenkins using jump host?

How to configure ssh server on jenkins using jump host?
Publish over SSH pluginprovide for a jump host option but not working.
I set up
Hostname : public ip (bastion server ip)
Username : ec2-user
in advance setting
Jump host: private ip (web application deployed server's private ip)
I opened ssh port on my was server. (open jenkins server ip connection)
and test connection result is here.
jenkins.plugins.publish_over.BapPublisherException: Failed to connect and initialize SSH connection. Message: [Failed to connect session for config [private]. Message [java.net.ConnectException: Connection timed out (Connection timed out)]]
How to deploy web application to server which is in private subnet.
There is a jenkins bug that seems to be still open:
https://issues.jenkins.io/browse/JENKINS-56119
I got the same error on testing configuration, but actual job is working over ssh jumphost.

Connecting to Amazon EC2 using Filezilla SFTP - Network error: Connection refused

I am completely new to Amazon EC2 and Filezilla. When I try to connect to the server, I am getting an error message: "Error: Network error: Connection refused"
The problem is that I can't get a complete tutorial on how to use Filezilla with Amazon EC2. I try to follow the steps in this post: Connect to Amazon EC2 file directory using Filezilla and SFTP, but it is still not working.
What I have done so far:
I add the following ports in the Security Group of my instance:
Turn off temporarily Windows firewall on my Remote machine (I am
using Windows Server 2016 Datacenter) and on my pc also.
Filezilla:
I imported my key file in Settings > Connection > SFTP, the file has
.pem as extension, I renamed it to .ppk before import but it is
still not working. I also try to convert it using PuttyGen but it
does not work.
Questions:
Are my ports correct in the inbound rules ?
Do I need to run Filezilla server (available in Xampp control panel)
on my remote machine ?
Additional Info:
When I try connecting to the server using FTP(insecure):
I get the following error message:
Try using username:
username = ec2-user