I have given below details of an SFTP server to login.

ipaddress, username, password, port(8800), password protected ppk file.

I tried the following command to login to server but unable to connect.(I expected giving password to the key after executing the command. And also I have password for both username and key).

sftp -i key.pem username@ipaddress -P8800

Error message

ssh: connect to host xx.xx.xx.xxx port 22: Connection timed out
Couldn't read packet: Connection reset by peer

But I am able to telnet to server using below command.

telnet ipaddress 8800

How is it telnet working but sftp command not working? And how to pass port number in sftp command?

2 Answers 2


You can see clearly from the error that you have pasted, that SFTP continues to attempt to connect on Port 22. Your '-P' arg is getting ignored.

Order of arguments is fairly important, or at least that 'username@ipaddress' should be at the end of the command is.

sftp  -P 8800 -i key.pem username@ipaddress

On RedHat/Fedora/CentOS there is no -i argument to sftp to specify a pem file - this is the syntax: sftp -P {port} -oIdentityFile={path to pem} {user}@{host}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.