Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ssh/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Postgresql 游走性postgres ssh隧道_Postgresql_Ssh_Vagrant - Fatal编程技术网

Postgresql 游走性postgres ssh隧道

Postgresql 游走性postgres ssh隧道,postgresql,ssh,vagrant,Postgresql,Ssh,Vagrant,我有一台写着博士后的流浪汉机器。我需要使用一些外部工具(例如pgmodeler、keetle)连接这个数据库。 因此,我开始使用: ssh -L 5433:127.0.0.1:5432 vagrant@192.168.56.140 -i puphpet/files/dot/ssh/id_rsa 然后我尝试使用以下命令登录: psql -h 127.0.0.1 -p 5433 -U postgres postgres 我得到一个错误: FATAL: password authenticatio

我有一台写着博士后的流浪汉机器。我需要使用一些外部工具(例如pgmodeler、keetle)连接这个数据库。 因此,我开始使用:

ssh -L 5433:127.0.0.1:5432 vagrant@192.168.56.140 -i puphpet/files/dot/ssh/id_rsa
然后我尝试使用以下命令登录:

psql -h 127.0.0.1 -p 5433 -U postgres postgres
我得到一个错误:

FATAL: password authentication failed for user "postgres"

我有点困惑,因为它过去能用,现在不行了。我试图设置用户密码,但没有成功。我应该在哪里查找问题?

您需要调整postgres服务器的
pg_hba.conf
文件,以告知postgres从何处可以连接哪些用户。在类似debian的发行版中,您可以在
/etc/postgresql/9.1/main/pg_hba.conf
中找到此文件

使用vagrant开发时,我通常使用pg_hba.conf中的以下条目允许所有用户无需密码即可从任何地方连接

# IPv4 connections from everywhere:
host    all             all             0.0.0.0/0               trust
切勿在生产服务器上使用此线路

在上面,我的文件中有一行转发端口

Vagrant.configure(2) do |config|
    # more stuff
    config.vm.network "forwarded_port", guest: 5432, host: 5433, host_ip: "127.0.0.1"
end

不要忘记将主机ip设置为localhost,否则postgres将绑定到本地计算机的所有网络接口。

为什么不使用vagrant转发端口?好啊所以我尝试了你们的解决方案,但问题仍然存在。我认为博士后有问题。可能在pg_hba.conf文件中?这是pg配置问题。显示流浪机器的pg_hba.conf。@JakubKania的可能副本这里是我的pg_hba.conf文件:
本地所有postgres ident
本地所有postgres ident
托管所有postgres 127.0.1/32 md5托管所有postgres 0.0.0/0拒绝
托管所有127.0.0.1/32 md5
host all::1/128 md5
OK。我发现了问题。在本地我也安装了Postgres。所以我需要关掉它,它现在可以工作了。但我不能同时拥有这两个端口吗?当然,您可以将Vagrantfile中的主机端口更改为例如5433,就像您使用隧道一样。