我设置了以下新贵脚本:
# autossh
description "autossh connections"
start on started dbus
stop on (runlevel [06] or stopped dbus)
respawn
respawn limit 5 60 # respawn max 5 times in 60 seconds
script
export AUTOSSH_PIDFILE=/var/run/autossh.pid
export AUTOSSH_POLL=60
export AUTOSSH_FIRST_POLL=30
export AUTOSSH_GATETIME=0
export AUTOSSH_DEBUG=1
exec sudo -H -u pi -s autossh -M 0 \
-R remoteport:127.0.0.1:localport remoteuser@remote.host
exec sudo -H -u pi -s autossh -M 0 \
-R remoteport2:127.0.0.1:localport2 remoteuser@remote.host
end script
Run Code Online (Sandbox Code Playgroud)
但每次启动后我都会收到此错误消息:
ssh 提前退出,状态为 0
我该如何修复它?
谢谢
我支持一家拥有远程托管网站的公司。他们使用 PostgreSQL 数据库。
我无法在远程服务器上编写脚本,并且不想在远程服务器上存储任何备份文件,但我可以运行 cron 作业,并且可以访问远程服务器的 SSH 公钥。我设置了本地 Linux 主机来接受远程主机的私钥进行身份验证。
我需要制作一个一行脚本来同步备份、压缩和 scp 备份文件到我的本地 Linux 机器。
如果我的本地 Linux 机器可以通过 SSH 在端口 122 上访问mylinuxbox.foo.com,并且我的数据库名称是mydatabase,那么这个单行 cron 作业命令会是什么样子?
我正在尝试编辑 etc/ssh (Ubuntu AWS EC2 服务器)文件夹中的 sshd_config 文件。我正在使用 FileZilla 更改端口,但无论我做什么,它都不会改变。
我收到一条错误消息:
Error: /etc/ssh/sshd_config: open for write: permission denied
Run Code Online (Sandbox Code Playgroud)
我尝试将权限更改为 600(当前为 644),但这也不起作用,错误提示:
set attrs for /etc/ssh/sshd_config: permission denied
Run Code Online (Sandbox Code Playgroud)
我也尝试将鱼片保存在我的桌面上,但什么也没发生 - 它只是说上传失败。
如果我尝试使用终端(在 Mac 上)访问服务器,我会得到以下信息:
ssh ubuntu@remote_host
Permission denied (publickey).
Run Code Online (Sandbox Code Playgroud)
我对 ssh 很陌生,并且正在努力学习它,所以如果我不太清楚,我深表歉意。
我想做的就是更改服务器端口并将其设置PermitRootLogin为no。
我正在尝试使用 ssh 从 OSX Mavericks 登录 AWS,但玩得很开心。我输入:
ssh -i ~/.ssh/filename.pem
ec2-user@ec2-xx-x-xxx-xx.compute-1.amazonaws.com -v
Run Code Online (Sandbox Code Playgroud)
我得到了这个,以及一个要求输入密码的钥匙串弹出窗口,即使没有提供密码......
debug1: key_parse_private_pem: PEM_read_PrivateKey failed
debug1: read PEM private key done: type <unknown>
Saving password to keychain failed.
Run Code Online (Sandbox Code Playgroud)
我在 AWS 上启动了一个新实例并生成了一个新密钥对。当我让 .pem 文件不受保护时,OSX 钥匙串弹出窗口不会出现,但我无法访问 AWS,因为该文件不受保护:
“/Users/cvn/.ssh/chris-test.pem”的权限 0644 过于开放。
要求您的私钥文件不能被
其他的。该私钥将被忽略。错误权限:忽略
密钥:/Users/cvn/.ssh/chris-test.pem 权限被拒绝(公钥)。
所以我跑了
chmod 400 chris-test.pem
Run Code Online (Sandbox Code Playgroud)
钥匙串返回并要求输入我没有的密码......
有没有办法使用 sftp 将远程文件系统上的文件复制到同一文件系统?
这意味着什么是
user@hostname:/path/file.txt从user@hostname:/path/copy_of_file.txt远程机器?我正在进行远程测试,需要在远程系统上复制一些大文件,而不需要将文件镜像到测试系统或从测试系统镜像文件。
我有一个不受密码保护的ssh 密钥,我用它来连接服务器。现在我想向密钥添加一个密码,所以我已经完成了:
ssh-keygen -p
Run Code Online (Sandbox Code Playgroud)
并添加了一个新的密码:
Enter file in which the key is (/home/user/.ssh/id_rsa):
Enter old passphrase:
Key has comment '/home/user/.ssh/id_rsa'
Enter new passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved with the new passphrase.
Run Code Online (Sandbox Code Playgroud)
然后,我尝试再次连接到服务器:
ssh user@server.com -v
Run Code Online (Sandbox Code Playgroud)
但我仍然在未输入密码的情况下登录:
debug1:可以继续的身份验证:publickey
debug1:下一个身份验证方法:publickey
debug1:提供RSA公钥:/home/user/.ssh/id_rsa
debug1:服务器接受密钥:pkalg ssh-rsa blen 279
debug1:身份验证成功(公钥)。
已通过 server.com ([xxx.xx.xxx.xx]:22) 验证。
为什么我没有被要求输入密码?
编辑:
Seahorse为我存储了密钥,所以这就是问题所在。
我有以下情况:
DevMachine (D) need to connect to a gateway/bastion server (G)
and then be able to talk to another server serving RabbitMQ (R) traffic on port 5672.
我尝试使用 ssh 隧道连接到网关:ssh -L 5672:localhost:5672 G接下来我希望网关实例让我连接到R5672。我该如何实现这一点?我觉得我在这里错过了一步。
我想要的是:D ->G -> R。我得到的是D ->G. 如果我有一个本地运行的rabbitmq实例G——这可以工作,但我想要的是本质上用作GVPN。
谢谢!
我无法使用 ssh id_rsa/id_rsa.pub 密钥,因为看起来 ssh 认为输入的密码是错误的。但我确信这是对的。它看起来是这样的:
ssh myuser@myhost_ip -i ~/.ssh/id_rsa.pub
The authenticity of host 'myhost_ip (myhost_ip)' can't be established.
RSA key fingerprint is SHA256: (some hash).
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'myhost_ip' (RSA) to the list of known hosts.
Enter passphrase for key '/Users/paul/.ssh/id_rsa.pub':
Enter passphrase for key '/Users/paul/.ssh/id_rsa.pub':
Enter passphrase for key '/Users/paul/.ssh/id_rsa.pub':
Run Code Online (Sandbox Code Playgroud)
据我了解,它认为密码是错误的。在这个问题之前,我还有另一个问题(我不确定,但也许它们是相关的?):
Permissions 0644 for '/Users/paul/.ssh/id_rsa.pub' are too open.
Run Code Online (Sandbox Code Playgroud)
我用 修复了它chmod 400 ~/.ssh/id_rsa.pub。我不确定为什么会出现这个问题,我猜测这些密钥是在 Ubuntu 上生成并转移到 MacOS 上的。 …
我创建了一个脚本来将 MongoDB 数据库复制到我的机器上。我正在创建一个 SSH 隧道 ( ssh -L ...),然后连接到隧道端口,mongodump然后将其输出通过管道传输到mongorestore:
mongodump --host=127.0.0.1:##### --db=***** --archive | mongorestore --host={mongo_dest} --drop --archive
Run Code Online (Sandbox Code Playgroud)
我想加快复制速度。--gzip在这种情况下使用没有意义 - 因为 和 使用相同的机器和mongodump内存mongorestore。数据通过 SSH 套接字未压缩。
有没有办法mongodump在 SSH 机器上运行并将其输出通过管道传输到我机器上的进程?
当然,我可以转储数据库、存档、通过 SSH 复制并恢复它。但我不想占用临时空间。
[本机为192.168.80.125]
允许所有基本访问的普通 SSH 规则:
AllowUsers user1
PubkeyAuthentication yes
PasswordAuthentication no
AllowTcpForwarding yes
UsePAM no
Run Code Online (Sandbox Code Playgroud)
匹配组测试
AllowUsers user2@IP1 user2@IP2 user2@IP3 user2@IP4
PubkeyAuthentication yes
PasswordAuthentication yes
AllowTcpForwarding yes
PermitOpen 192.168.80.100:80
PermitOpen 192.168.80.125:443
AllowAgentForwarding no
Run Code Online (Sandbox Code Playgroud)
当我以 user2 身份从 IP1 连接到 sshd 时,我可以使用 PuTTY 打开隧道:
本地S:IP1:8080 远程D:192.168.80.100:80
本地源:IP1:8443 远程目标:192.168.80.125:443
我打开浏览器并浏览到 localhost:8080 我得到连接重置。我打开浏览器并浏览到 localhost:8443 我得到连接重置。
我检查 SSH 日志:
192.168.80.125 authlog: Received request to connect to host 192.168.80.100 port 80, but the request was denied.
192.168.80.125 authlog: Received request to connect to host 192.168.80.125 port 443, …Run Code Online (Sandbox Code Playgroud) ssh ×10
ssh-keys ×2
ssh-tunnel ×2
ubuntu ×2
backup ×1
bastion ×1
cron ×1
forwarding ×1
linux ×1
mac-osx ×1
mongodb ×1
postgresql ×1
security ×1
sftp ×1
socket ×1
ssh-keygen ×1
upstart ×1
vpn ×1