将自己锁定在 Amazon EC2 SSH 之外 - 此服务仅允许 sftp 连接

Jam*_*tal 5 ssh putty sshd

多。

乱搞后在Amazon EC2箱把自己锁在了SSH的 ForceCommand internal-sftp/etc/ssh/sshd_config为了让root登录通过SFTP。

SFTP 仍然可以正常工作,但 PuTTY 立即死亡,例如:

油灰

奇怪的是,SFTP 仍然可以正常工作,并且允许我按root当前方式登录(因为我所做的更改) - 所以我打开了一个 WinSCP 窗口,我可以浏览我喜欢的任何内容并编辑内容。

当我尝试使用以下方法从另一个 Linux 机器连接时:

ssh -i keyfile.pem ec2-user@hostname.com.au -p [portnumber]
Run Code Online (Sandbox Code Playgroud)

我收到以下回复:

This service allows sftp connections only.
Connection to [hostname] closed.
Run Code Online (Sandbox Code Playgroud)

我已成功移除ForceCommand internal-sftp/etc/ssh/sshd_config但在service ssh restart远程运行时遇到问题。当我sftp使用!前缀进行操作时,它说它有效 - 但我可以说它没有,因为侦听端口没有改变。

Jam*_*tal 6

ForceCommand internal-sftp/etc/ssh/sshd_config服务器中删除并重新启动(以刷新配置文件),然后我又回来了。