Articles of ssh

设置一个只能用于socks5代理的ssh帐户

我有一个防火墙后面的arch linux机器。 我可以打开ssh端口的端口转发。 我想创build一个只能用于袜子代理的用户。 ssh -N -D 5000 user@server -p9000 5000将是用户使用socks5代理的本地端口 server:9000是server:9000的ssh端口(端口转发) -N意味着一个terminal不应该被打开。 我将创build一个默认shell为/sbin/nologin 。 现在问题是用户可以转发本地端口( -L8080:server2:80 ),我想避免这种情况。 另外我希望代理服务器的内部networking没有代理连接任何东西。 这是否容易实现? 我还有其他的陷阱吗?

连接到postgresql挂在OSX上的SSH隧道上

尝试连接到OSX上的远程PG服务器,但它保持超时。 首先,我build立了隧道: ssh -L 5433:serverip:5432 user@serverip 然后在一个单独的terminal,我尝试连接到PG: psql -h localhost -p 5433 -U user 这里的连接只需要3分钟。 然后我得到以下消息: psql: server closed the connection unexpectedly This probably means the server terminated abnormally before or while processing the request. 在ssh隧道terminal上,我看到的只是这个: channel 3: new [direct-tcpip] (3 mins later:)channel 3: open failed: connect failed: Connection timed out 我试过了我能想到的所有变化(localhost vs 127.0.0.1,diff用户名)。 没有任何工作。 […]

如何记住/caching或指定Ansible的私钥密码

刚开始使用Ansible时,我在客户端机器上build立了一个Asible用户,并从OpenSSL创build了一组密钥。 我以自己的账户运行Ansible。 我已经在Ansibleconfiguration中指定了用户和私钥文件。 我想让远程命令以这个用户和这个用户的身份运行,以执行需要提升的命令。 /etc/ansible/ansible.cfg private_key_file = /etc/ansible/pka/confman.crt remote_user = confman 像这样的命令在初始input密码之后不要求密码: ansible all -m ping 每次运行密码时都会出现以下提示: ansible all -m ping -b Enter passphrase for key '/etc/ansible/private_keys/confman.crt': (success) ansible all -m ping –sudo Enter passphrase for key '/etc/ansible/private_keys/confman.crt': (success) ansible all -a "cat /etc/redhat-release" Enter passphrase for key '/etc/ansible/private_keys/confman.crt': (success) 为什么? 有没有办法设置密码? 有没有更安全的方法? 我计划通过cron和其他自动化工具远程运行安全性,因为input密码不是一个选项。 作为上下文,我从来不需要SSH服务器之间的SSH,总是从Windows机器使用诸如腻子,RoyalTS和mRemoteNG等工具,所以我的SSH知识是…稀疏。 […]

在CentOS 7服务器上无法使用共享密钥ssh拒绝我们的密钥

我无法使用预共享密钥ssh到CentOS 7服务器,我得到一个“服务器拒绝我们的密钥”消息。 下面是使用-vv的ssh尝试 OpenSSH_7.2p2, OpenSSL 1.0.2h-fips 3 May 2016 debug1: Reading configuration data /etc/ssh/ssh_config debug1: /etc/ssh/ssh_config line 56: Applying options for * debug1: /etc/ssh/ssh_config line 67: Deprecated option "useroaming" debug2: resolving "my.server.net" port 22 debug2: ssh_connect_direct: needpriv 0 debug1: Connecting to my.server.net [xxx.xxx.xxx.xxx] port 22. debug1: Connection established. debug1: identity file /home/user/.ssh/id_rsa type 1 debug1: […]

在/ etc / hosts或ssh_config中使用别名

我已经configuration了堡垒或(跳转)框来访问虚拟专用networking。 #ssh_config Host bastion HostName 14.90.140.120 User me IdentityFile ~/.ssh/me ForwardAgent yes Host 10.1.* User me IdentityFile ~/.ssh/me ProxyCommand ssh bastion -W %h:%p 我能够ssh入堡垒和10.1.1.6地址没有问题。 我想要做的是添加一个条目,如下所示。 注意:目前我还没有时间使用DNS,但这将是我的首选方法。 #/etc/hosts 10.1.1.6 my-host-inside-vpc.corp.internal 当我这样做,然后尝试访问该机器,我得到以下 ➜ ~ ssh -vvv my-host-inside-vpc.corp.internal debug1: Reading configuration data /home/me/.ssh/config debug1: /etc/ssh/ssh_config line 19: Applying options for * debug2: ssh_connect: needpriv 0 debug1: Connecting to […]

用Ansible处理键盘交互input

我已经安装了几个GNU / Linux(Ubuntu和Amazon Linux)服务器,以便使用PAM的google-authenticator模块和keyboard-interactive:pam SSHD身份validation方法来提示基于时间的OTP。 我正在努力争取让我进入OTP。 在进行连接之前,– –ask-pass标志要求提供密码,并在进行连接时传递该密码。 我需要的是只要将来自服务器上SSHD的OTP请求传递给我的shell。 有什么办法可以做到吗? 目前,ansible不能可靠地将响应传递回服务器。 ➜ ansible git:(master) ✗ ansible -m ping amazon1 –inventory-file=./ansible_hosts Verification code: <I QUICKLY ENTER THE OTP HERE> amazon1 | UNREACHABLE! => { "changed": false, "msg": "Failed to connect to the host via ssh.", "unreachable": true } 在amazon1上的sshd_config …snip… UsePAM yes PubkeyAuthentication yes ChallengeResponseAuthentication yes […]

在RHEL 6.8中打开防火墙端口

我正在努力确定是否根据Redhat 6.8中的防火墙打开特定的端口 我想打开2222端口。 我已经尝试了以下内容: system-config-firewall,以sudo的身份运行,并将端口2222描述为要打开的特定端口: 然而,港口并不公开。 我通过尝试通过SSH连接到2222端口来testing。目前SSH运行在22端口上,而且我可以正常连接,但是当我configurationSSH通过2222运行时,使用/ etc / ssh /中sshd_config中的Port 2222 ,连接超时。 我知道SSHD被configuration为侦听该端口,因为我可以使用netstat来testing。 我也尝试过对/ etc / sysconfig / iptables进行各种编辑,包括添加下列规则: -I INPUT 9 -m state –state NEW -m tcp -p tcp –dport 2222 -j ACCEPT 和 -A INPUT -m state –state NEW -m tcp -p tcp –dport 2222 -j ACCEPT 每一个这些变化后,我执行sudo service iptables restart ,我无法连接。 […]

连接由<ip> closures

我在Ubuntu服务器上。 我正在尝试启用SSH隧道,以便在我的项目中添加git remote。 在我本地的win7机器上,我用PuTTYgen生成密钥对。 我把公钥粘贴在authorized_keys文件中 我将私人PuTTY ppk文件path设置为putty Authconfiguration 当我尝试打开一个远程shell我得到错误Server refused our key 。 检查日志: Connection closed by <ip> [preauth] /var/log/auth.log Connection closed by <ip> [preauth] 。 更多信息: ~/.ssh/authorized-keys有权限664。 该文件被命名为authorized-keys not authorized_keys这可能是一个问题? 我错过了什么?

使用EB ssh访问权限的人员

最近有人离开了我们的组织,他们为我们的生产Amazon ElasticBeanstalk环境提供了SSH密钥。 这种情况通常如何处理? 是否创build了一个新的密钥对,然后分配给其他有权访问的人? 有一个pipe理EB ssh密钥的最佳做法吗? 编辑: 我们最终所使用的技巧是将authorized_keys文件存储在安全的S3存储桶中,并将内容与/home/ec2-user/.ssh/authorized_keys合并在本SO问题提供的答案中。 对于刚刚joinElasticBeanstalk的人来说,一个重要的细节就是它实际上只是对其他AWS服务的抽象,并且还有一些缺陷需要你自己填写。

奇怪的sshd日志消息每分钟

我的linux系统在/ var / log / secure中每隔一分钟都会收到这个错误消息 Jun 14 04:24:28 mybox sshd[19741]: Connection closed by 127.0.0.1 Jun 14 04:25:28 mybox sshd[19764]: Connection closed by 127.0.0.1 Jun 14 04:26:28 mybox sshd[19770]: Connection closed by 127.0.0.1 Jun 14 04:27:28 mybox sshd[19776]: Connection closed by 127.0.0.1 Jun 14 04:28:28 mybox sshd[19782]: Connection closed by 127.0.0.1 Jun 14 04:29:28 mybox […]