Problem with SFTP Command line, "@" in username.

Hi Guys Any help is appreciated very much!

I'm trying to use SFTP to an external server using the native SFTP Client in RHEL 6 and 7.

I've been given a username on the remote SFTP Server of myemail@myorg.com.

I can not seem to escape that @ sign no matter what I do.

I've tried these examples and several other iterations of the same thing:

sftp "myemail\@myorg.com" remoteftpsite.com
sftp 'myemail@myorg.com' remoteftpsite.com
sftp myemail\@myorg.com' remotesftpsite.com
sftp myemail\100myorg.com remotesftpsite.com

For whatever reason, I can not simply get it to connect using the credentials myemail@myorg.com.

Any help is appreciated very much!!

Try:

sftp 'myemail@myorg.com'@remoteftpsite.com

That way wont connect at all.

What do you think of that "port 22:11" I've never seen that before...

# sftp 'myemail@myorg.com'@ftpsite.com
#BANNER#
Received disconnect from #IP ADDRESS# port 22:11: Application error
Authentication failed.
Couldn't read packet: Connection reset by peer

Something is really wrong here. Most UNIX usernames are not as long as the myemail@myorg.com and some UNIX systems limit the length. I do not think that was meant as a username. It is an ssh connect string.

What does

ssh myemail@myorg.com

show?
I realize that is probably a name you made up for the question.

Next question: did you personally get ssh keys for ftpsite.com for that myemail user for myorg.com?

Last question: This was probably intended as a 'three-way' connection

  1. ssh to myorg.com (as user myemail) with you owning ssh keys
  2. then sftp from myorg.com to ftpsite, send files created by myemail on myorg.com to ftpsite.

Was this ever explained to you this way?

Yes, something definitely off!

ssh myemail@myorg.com wont work, not even with the real data, i'd be doing an ssh to my own domain.

No I don't have ssh keys, I was given a user ID and a password from the vendor running the SFTP Site.

For the last question.. No.

They gave me a user id and password to login to their sftp server in the following format:

SFTP User Name = myemailaddress@mydomain (its my email address)
Password = Regular clear text password.

I am able to get it to work correctly using psftp from a windows command line.

C:\Windows\system32>psftp -l myuserid@myorg.com sftpsite.com
Using username "myuserid@myorg.com".
Property of #Company# Systems. Unauthorized use prohibited.
myuserid@myorg.com@sftpsite.com's password:
Remote working directory is /
psftp>

I can also get it to work using the filezilla windows client.

how about....

sftp -oUser='myemail@myorg.com' remoteftpsite.com

or loose the single quotes......

I tried it with both regular and double quotes.

# sftp -o User='myuser@myorg.com' sftpsite.com
Property of #Company# Systems. Unauthorized use prohibited.
Received disconnect from # SFTP Server IP ADDRESS # port 22:11: Application error
Authentication failed.
Couldn't read packet: Connection reset by peer

this is not what I suggested - loose the space after -o
Also try it withOUT quotes.
man sftp

1 Like

Look for the port entry in the configuration files...

This is what's valid to put in a UNIX username:

[a-z_][a-z0-9_-]*[$]?

No @.

I find this discussion interesting. I thought I was familiar with email addresses being used as userid's on sFTP and therefore, by default, containing the @ character. I'm sure that I remember this from years ago.

Searching the web these pages seem relevant:

shell - command line sftp: email address as username - Stack Overflow

ssh - How do I sftp to a server if the username contains @ symbol - Unix & Linux Stack Exchange

From your post#7 it seems to me that, since the error mentions 'port' (for the first time????) that the server may not be listening on default port 22 and, if so, a port number would need to be included on your command line. Perhaps talk to the remote server's sysadmin and confirm which port number sFTP is on.

You have a lot of skilled subscribers to this thread now so I'll be interested to see how this develops.

Good luck.

This is correct, but this is not a UNIX username: it rather is an identification similar to what in past times was used in (anonymous) ftp where one entered his own email address. This probably is a chrooted anonymous sftp-server thread-o/p is connecting to.

I hope this helps.

bakunin

I've opened a case with Red Hat support. I will post the results.

---------- Post updated at 08:06 PM ---------- Previous update was at 07:25 PM ----------

@vgersh99

[root@MyServer ~]# sftp -oUser='myemail@myorg.com' sftpsite.com
Property of #Company# Systems. Unauthorized use prohibited.
Received disconnect from # IP ADDRESS # port 22:11: Application error
Authentication failed.
Couldn't read packet: Connection reset by peer


[root@MyServer ~]# sftp -oUser=myemail@myorg.com sftpsite.com
Property of #Company# Systems. Unauthorized use prohibited.
Received disconnect from #IP ADDRESS# port 22:11: Application error
Authentication failed.
Couldn't read packet: Connection reset by peer
[root@MyServer ~]#

---------- Post updated at 08:13 PM ---------- Previous update was at 08:06 PM ----------

[root@Myserver ~]# bash -version
GNU bash, version 4.2.46(2)-release (x86_64-redhat-linux-gnu)
Copyright (C) 2011 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
[root@Myserver ~]# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 7.4 (Maipo)
[roott@MyServer ~]#

---------- Post updated at 08:23 PM ---------- Previous update was at 08:13 PM ----------

It seems they are running proFTPD:

This is from my debug output:

debug1: Remote protocol version 2.0, remote software version mod_sftp/0.9.8
debug1: no match: mod_sftp/0.9.8
debug2: fd 3 setting O_NONBLOCK
debug1: Authenticating to sftpsite.com

---------- Post updated at 08:33 PM ---------- Previous update was at 08:23 PM ----------

Trying to escape the @

[root@MyServer ~]# sftp -oUser='myemail\@myorg.com' sftpsite.com
Property of #Company# Systems. Unauthorized use prohibited.
myemail\@myorg.com@sftpsite.com password:

---------- Post updated at 08:35 PM ---------- Previous update was at 08:33 PM ----------

[root@MyServer ~]# sftp -oUser=myemail\@myorg.com sftpsite.com
Property of #Company# Systems. Unauthorized use prohibited.
Received disconnect from #IP Address# port 22:11: Application error
Authentication failed.
Couldn't read packet: Connection reset by peer
[root@MyServer ~]#

sftp is not ftp. It's ssh, fundamentally - a shell login.

Hi Guys,

They changed something on their side (didn't tell me what) and now it works.

Here was my original example where it would simply disconnect:

# sftp 'myemail@myorg.com'@ftpsite.com
#BANNER#
Received disconnect from #IP ADDRESS# port 22:11: Application error
Authentication failed.
Couldn't read packet: Connection reset by peer

Here it is now asking for a password as it should:

# sftp 'myemail@myorg.com'@sftpsite.com
#BANNER#
myemail@myorg.com@sftpsite.com's password:

Thank you everyone for you help working through this.

Your ' ' single quotes are superfluous as only the shell sees them, not sftp. Probably nothing needed to change on your end at all.

Yes, something definitely off!