Copy file or directory from remote server - command-line

I try to copy file from remote server to my local machin but it gives following error
ssh: connect to host 103.241.144.137 port 22: Connection refused.
command : scp root#111.111.111:/home/msecondo/public_html/jsp/afterLogin/sachin/PHR/ /localpth/.

"Connection refused" means that there was no process accepting connections at the IP address and port that your client tried to connect to. In this case, it probably means that there is no SSH server running at 103.241.144.137 port 22. Alternately, if the SSH server is running, it may not be listening on the IP address or port that you tried to connect to.
StackOverflow isn't the right site for troubleshooting SSH server configuration. If you have administrator privileges on the remote server, then you should look into how the SSH server is configured and whether it's running. If you're not an administrator on the remote server, you should report this to the administrators so that it can be investigated.

Related

Problem to connect to an AWS postgres instance via a bastion host via SSHTunnel in python

I have an AWS postgres instance and an AWS ec2 instance (running as bastion host). From my local machine I want to connect to that AWS postgres instance via a python script. But it's not working (see below).
My setup is:
with SSHTunnelForwarder(
('internet-adress-of-the-basion-host', 22),
ssh_private_key=r"the-private-key.pem",
ssh_username="ec2-user",
local_bind_address=('localhost', 6543),
remote_bind_address=('internet-adress-of-the-postgres-server', 5432)) as server:
server.start()
print("server connected")
self.conpostgres = psycopg2.connect(host='localhost', port=server.local_bind_port, database="the-database",
user="the-user", password="the-password")
I can sucessfully connect via the sshtunnel (the "server connected" messages is printed to the console), but I get an ERROR in the when excecuting psycopg2.connect.
The connect ERROR is:
could not connect to server: Connection refused (0x0000274D/10061)
Is the server running on host "localhost" (::1) and accepting
TCP/IP connections on port 6543?
FATAL: password authentication failed for user "the-user"
FATAL: no pg_hba.conf entry for host "x.x.x.x", user "the-user", database "the-database", SSL off
Two remarks:
1.) In the line "no pg_hba.conf entry for host "x.x.x.x"". Here the "x.x.x.x" address is NOT localhost (127.0.0.1). It's a normal ip4 internet address. But I have no idea where this address is coming from!
2.) !!!! With the exact same configuration mentioned above I can successfully connect to the database via the database tool built in IntelliJ Idea. So there is a way to connect to the postgres server without changing pg_hba.conf. So maybe I have to configure the tunnel differently?

Remote access to postgresql server windows 10

As the title suggest I'm trying to configure a postgresql server to be accessible remotely. I've followed many guides and viewed some of the other answers here however I'm still having trouble.
The details:
os, windows 10
postgresql version on host is 11.6
postgresql version on remote is 11.2 with anaconda install
I have changed the pg_hba.conf and postgresql.conf to allow for connections to the server.
More specifically I've added the line
host all all xxx.xx.x.0/0 trust
I can verify that the host is listening on local address 0.0.0.0:5432 via netstat.
I can ping the ip of the host from the remote, and I have set windows firewalls on the host to allow connection.
Yet I still recieve the following error when trying to access psql from the remote.
psql: could not connect to server: Connection timed out (0x0000274C/10060)
Is the server running on host "xxx.xx.x.144" and accepting
TCP/IP connections on port 5432?```
I had to double check the windows firewall permissions. The connection was enabled but the application was not set to allowed. It turns out a local user can enable connection but I needed the system admin to set the application executable to allowed by the windows fire wall.

Connect to remote postgres server from EC2 Instance

I am trying to fetch data from the Postgres server which is remotely available from Amazon EC2 instance. When I try to telnet the remote server, it is connected.
But when I am running a kafka connector which connects to the remote Postgres server it throws an error stating
FATAL: no pg_hba.conf entry for host, SSL off for configuration Couldn't open a connection to jdbc:postgresql://<url>
I tried changing the connection string from
jdbc:postgresql://host:5432/schema_name?user=******&password=******&defaultFetchSize=250000&useCursorFetch=true
to
jdbc:postgresql://host:5432/schema_name?ssl=true&user=******&password=******&defaultFetchSize=250000&useCursorFetch=true
then it throws another error which is
The server does not support SSL. for configuration Couldn't open a connection to jdbc:postgresql://<url>
There is no SSL support in the Postgres server because I can connect to the server through any DB connector without ssh. I am sure it has to do something with the security access group of EC2(considering I can telnet to the server from the instance). Any help would be much appreciated.
Looks like error is in the pg_hba.conf. I would have put this as a comment but not enough rep.
When you telnet to the server did you use the db port?
Can you post your pg_hba.conf file. This is one off my home dev server. You'll need to add a line similar to this: host all all 192.168.1.1/24 md5 with your IP addr and details.
If you're using this in a corporate network I'd highly recommend looking at a amazon VPC and not to expose your database to the internet.
# TYPE DATABASE USER ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all peer
# IPv4 local connections:
host all all 127.0.0.1/32 md5
host all all 10.10.187.1/24 md5

Error on Virtual machine Bluemix connection

I do not get connection with this VM: ssh ibmcloud#129.41.147.70
ssh: connect to host 129.41.147.70 port 22: Network is unreachable
Could it be that firewall rules now prevent me to connect to
129.41.147.70?
I believe you need to specify the ssh key, like:
ssh -i your_public_key ibmcloud#129.41.147.70
Also, check if the VM is runnning in the Bluemix UI and if you can ping the server from your machine.
Actually if you can ping it, it is likely a firewall issue with the error you are seeing.

PostgreSQL SSH port forwarding via Windows/PuTTY

I have PostgreSQL 9.4 running on a Linux VPS, and I need to be able to connect to it over SSH from both Linux and Windows clients. (I will later need to connect to multiple servers, and so that all clients use the same port numbers, I'm forwarding to port 5551 for the first server, then I will use 5552, 5553, etc.)
From a Linux client I just run ssh -fNg -L 5551:localhost:5432 user#remote1.com and connect to localhost:5551 with PGAdmin3 or any other client app. Works great.
On Windows, I'm using PuTTY and Pageant. I got the connection to user#remote1.com via terminal working, then I went to the SSH Tunnels and added L5432 localhost:5551. Terminal connection still works, but when I try to connect with PGAdmin3 to localhost:5551 I get an error:
could not connect to server: Connection refused (0x0000274AD/10061) Is the server running on host "localhost" (::1) and accepting TCP/IP connections on port 5551?
I resolved it. Like many things, this is obvious in hindsight. I had things backward in the SSH Tunnels setup in PuTTY. It needs to be L5551 remote1.com:5432