Doh.
Locked myself out of SSH on an Amazon EC2 box after fiddling with
ForceCommand internal-sftp
in /etc/ssh/sshd_config
in order to allow root
log-in via SFTP.
SFTP still works fine, but PuTTY dies instantly, e.g:
The odd thing here is that SFTP still works fine and permits me to log-in as root
currently (because of the changes I made) - so I've got a WinSCP window open and I can trawl through whatever I like and edit stuff.
When I try to connect from another Linux box using:
ssh -i keyfile.pem ec2-user@hostname.com.au -p [portnumber]
I get the following response:
This service allows sftp connections only.
Connection to [hostname] closed.
I've successfully removed ForceCommand internal-sftp
from /etc/ssh/sshd_config
but I'm having trouble running service ssh restart
remotely. When I do it from sftp
with the !
prefix, it says it's worked - but I can tell that it hasn't because the listening port is not changing.
authorized_keys
? They should be your public keys not your private keys. – Anthon Jul 11 '14 at 6:55ForceCommand internal-sftp
is not needed forsftp
to work, but it will stop shell login. Have you restartedsshd
after fixingsshd_config
? – ctrl-alt-delor Jul 11 '14 at 8:26authorised_keys
is fine: you have no configuration fields, and if sftp works then the key is ok. – ctrl-alt-delor Jul 11 '14 at 8:28