LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-18-2014, 09:24 AM   #1
linuxmantra
Member
 
Registered: Dec 2013
Posts: 104

Rep: Reputation: Disabled
ftp server


I created external ftp server. Installed proftpd and configured it as per the documentation of my company. Created a directory userftponly and inside that directory created directory for users and users are added. I see, to test ftp server command used was :

# sftp user@localhost:2222

Can any one tell me, what this command actually does and how does it verify that my ftp server is configured properly.

Thank you in advance.
 
Old 06-18-2014, 09:38 AM   #2
eklavya
Member
 
Registered: Mar 2013
Posts: 619

Rep: Reputation: 136Reputation: 136
Code:
     sftp is an interactive file transfer program, similar to ftp, which
     performs all operations over an encrypted ssh transport.  It may also
     use many features of ssh, such as public key authentication and compres‐
     sion.  sftp connects and logs into the specified host, then enters an
     interactive command mode.
Quote:
Originally Posted by linuxmantra View Post
# sftp user@localhost:2222
It tries to log into user's account of localhost, if user does not exist, it says
Code:
Permission denied, please try again.
Now user and password both are correct,it tries to find filename 2222, if it does not find, it says.
Code:
Couldn't stat remote file: No such file or directory
To find out ftp is working or not, try to login with ftp user and see if you are able to do so or not, if you have made user jailed in directory, check the user is jailed or not and most important if you are able to loginto the account, can you upload and download files for which you have installed ftp.

Last edited by eklavya; 06-18-2014 at 09:48 AM.
 
Old 06-18-2014, 10:27 AM   #3
linuxmantra
Member
 
Registered: Dec 2013
Posts: 104

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by eklavya View Post
Code:
     sftp is an interactive file transfer program, similar to ftp, which
     performs all operations over an encrypted ssh transport.  It may also
     use many features of ssh, such as public key authentication and compres‐
     sion.  sftp connects and logs into the specified host, then enters an
     interactive command mode.
It tries to log into user's account of localhost, if user does not exist, it says
Code:
Permission denied, please try again.
Now user and password both are correct,it tries to find filename 2222, if it does not find, it says.
Code:
Couldn't stat remote file: No such file or directory
To find out ftp is working or not, try to login with ftp user and see if you are able to do so or not, if you have made user jailed in directory, check the user is jailed or not and most important if you are able to loginto the account, can you upload and download files for which you have installed ftp.

Some contents of proftpd.conf file:
ServerName "ProFTPD server"
ServerIdent on "FTP Server ready."
ServerAdmin root@localhost
DefaultServer on

VRootEngine on
DefaultRoot ~ sftponly,!users
VRootAlias /etc/security/pam_env.conf etc/security/pam_env.conf

As we can notice, DefaultRoot ~ sftponly,!users, it means users are jailed, right??
 
Old 06-18-2014, 04:05 PM   #4
linuxmantra
Member
 
Registered: Dec 2013
Posts: 104

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by eklavya View Post
Code:
     sftp is an interactive file transfer program, similar to ftp, which
     performs all operations over an encrypted ssh transport.  It may also
     use many features of ssh, such as public key authentication and compres‐
     sion.  sftp connects and logs into the specified host, then enters an
     interactive command mode.
It tries to log into user's account of localhost, if user does not exist, it says
Code:
Permission denied, please try again.
Now user and password both are correct,it tries to find filename 2222, if it does not find, it says.
Code:
Couldn't stat remote file: No such file or directory
To find out ftp is working or not, try to login with ftp user and see if you are able to do so or not, if you have made user jailed in directory, check the user is jailed or not and most important if you are able to loginto the account, can you upload and download files for which you have installed ftp.
I logged in a ftp server (running RHEL 6.4) using my user account and tried:

# sftp txkk@localhost:2222
Connecting to localhost...
txkk@localhost's password:
Couldn't stat remote file: No such file or directory
File "/home/txkk/2222" not found.

I got exactly what you mentioned. But when i tried to login as sftp user. Please note that, I created separate filesystem and mounted at /home/sftuser and inside it, I created directory for the sftp users. Everything is done on a part of user (UID,gid etc).
Now, what I did is:

# sftp hxftp@localhost:2222 (hxftp is a ftp user jailed in /home/sftuser directory)
hxftp@localhost's password:
Permission denied, please try again.
hxftp@localhost's password:
Permission denied, please try again.
hxftp@localhost's password:

Any suggestion...
 
Old 06-19-2014, 01:20 AM   #5
eklavya
Member
 
Registered: Mar 2013
Posts: 619

Rep: Reputation: 136Reputation: 136
So Basically What is 2222, if it is a port then this is not the correct place to use it and if it is directory, you have to give absolute path.
Suppose directory 2222 is inside the user's home directory. You have to give path like
Code:
sftp user@localhost:/home/user/2222
/home/user/2222 should be path of the directory on the system and you have to give the path. Now the message should be
Code:
Changing to: /home/user/2222
If you have jailed user in the directory 2222, Now when you log in, it takes you inside the 2222. Just Run
Code:
sftp user@localhost
If the jailed directory is defined, you don't need to give path of it, you will be inside it.

For your permission denied problem, have you set password for the users which you created.
If they are ftp users, have you tried to log into their account using ftp (filezilla), does it give you
Code:
530 login incorrect
For sftp chrrot settings,Take a look here.
http://www.thegeekstuff.com/2012/03/chroot-sftp-setup/

Last edited by eklavya; 06-19-2014 at 01:22 AM.
 
Old 06-20-2014, 02:06 AM   #6
karim.ouda
Member
 
Registered: Jun 2013
Posts: 41

Rep: Reputation: 3
ftp and sftp are two different programs.
ftp runs on port 21 but sftp runs on port 22. sftp uses ssh transport to transfer data.
Do not confuse ftps with sftp. ftps protects FTP data as it travels over the network using SSL encryption.

If you are trying to login using sftp, the port 22 (I assume it is default) should be opened.
A user can be logged into the system using ftp and sftp both if it is allowed.

You have mounted your system into /home/sftuser and here you have created users. if there are three users created, it means
/home/sftuser/user
/home/sftuser/txkk
/home/sftuser/hxftp
they should be the path of user directories.
Now by default user's are already jailed into it's home directory, you do not need to set it.
if user txkk's home directory path is /home/sftuser/txkk, it will be logged into this directory automatically when you use
Code:
sftp txkk@localhost
Connecting to localhost...
txkk@localhost's password:
sftp>
Now you are inside the directory /home/sftuser/txkk, user does not need to know the absolute path to be logged in it's home directory.

If 2222 is a directory inside any user's home directory and you want every user should be jailed in the 2222.
You need to change the permissions because 2222 is created into a user's home directory and you want another user should be logged into it.
Read this web page, it is for ubuntu but the permission setting process is helpful.
http://askubuntu.com/questions/28089...p-denies-login
 
Old 06-20-2014, 10:06 AM   #7
linuxmantra
Member
 
Registered: Dec 2013
Posts: 104

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by karim.ouda View Post
ftp and sftp are two different programs.
ftp runs on port 21 but sftp runs on port 22. sftp uses ssh transport to transfer data.
Do not confuse ftps with sftp. ftps protects FTP data as it travels over the network using SSL encryption.

If you are trying to login using sftp, the port 22 (I assume it is default) should be opened.
A user can be logged into the system using ftp and sftp both if it is allowed.

You have mounted your system into /home/sftuser and here you have created users. if there are three users created, it means
/home/sftuser/user
/home/sftuser/txkk
/home/sftuser/hxftp
they should be the path of user directories.
Now by default user's are already jailed into it's home directory, you do not need to set it.
if user txkk's home directory path is /home/sftuser/txkk, it will be logged into this directory automatically when you use
Code:
sftp txkk@localhost
Connecting to localhost...
txkk@localhost's password:
sftp>
Now you are inside the directory /home/sftuser/txkk, user does not need to know the absolute path to be logged in it's home directory.

If 2222 is a directory inside any user's home directory and you want every user should be jailed in the 2222.
You need to change the permissions because 2222 is created into a user's home directory and you want another user should be logged into it.
Read this web page, it is for ubuntu but the permission setting process is helpful.
http://askubuntu.com/questions/28089...p-denies-login
2222 is not a directoyr,its a port that is set in proftpd.conf file:
SFTPEngine on
Port 2222
 
Old 06-21-2014, 11:39 AM   #8
battles
Member
 
Registered: Apr 2014
Distribution: Debian GNU/Linux 7.5 (wheezy)
Posts: 231

Rep: Reputation: 5
I am going to throw a not too on topic note in here because I have seen others ask about this in LQ in the past. I needed to send a file from my server to another server and found that sftp would can not pass a password. I found that Putty has a Linux version on their site that I compiled on my server. I now can pass the username/password to the other server and automatically load the file daily with a cron.

See:

Release source code for Unix
http://www.chiark.greenend.org.uk/~s.../download.html
 
Old 06-26-2014, 08:45 AM   #9
karim.ouda
Member
 
Registered: Jun 2013
Posts: 41

Rep: Reputation: 3
Quote:
Originally Posted by linuxmantra View Post
2222 is not a directoyr,its a port that is set in proftpd.conf file:
SFTPEngine on
Port 2222
I think, the non default port 2222 has been defined in the file sshd_config of the server as well as you have restarted the ssh daemon if you had made any changes in config file of the ssh.

If port is not default port and you have not mentioned it in sftp command, you can get error

Code:
ssh: connect to host localhost port 22: Connection refused
Couldn't read packet: Connection reset by peer
Try this :
Code:
sftp -oPort=2222 txkk@localhost
Now enter password of the user txkk and you will be in the home directory of the user txkk
Code:
sftp -oPort=2222 txkk@localhost
Connecting to localhost...
txkk@localhost's password: 
sftp>
 
Old 06-28-2014, 12:34 PM   #10
linuxmantra
Member
 
Registered: Dec 2013
Posts: 104

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by karim.ouda View Post
I think, the non default port 2222 has been defined in the file sshd_config of the server as well as you have restarted the ssh daemon if you had made any changes in config file of the ssh.

If port is not default port and you have not mentioned it in sftp command, you can get error

Code:
ssh: connect to host localhost port 22: Connection refused
Couldn't read packet: Connection reset by peer
Try this :
Code:
sftp -oPort=2222 txkk@localhost
Now enter password of the user txkk and you will be in the home directory of the user txkk
Code:
sftp -oPort=2222 txkk@localhost
Connecting to localhost...
txkk@localhost's password: 
sftp>
root@server01:~# sftp -oPort=2222 txkk@localhost
Connecting to localhost...
txkk@localhost's password:
Permission denied, please try again.
txkk@localhost's password:
Permission denied, please try again.
txkk@localhost's password:
txkk@localhost's password:
Permission denied (keyboard-interactive,password).
Couldn't read packet: Connection reset by peer

I also tried:

root@server01:~# sftp txkk@localhost -p2222

Connecting to localhost...
txkk@localhost's password:
subsystem request failed on channel 0
Couldn't read packet: Connection reset by peer

Please note that sftp is occuring at port 2222. Configuration is set in proftpd.conf file and daemon is running..
Any suggestion..!!!

Last edited by linuxmantra; 06-28-2014 at 12:36 PM.
 
Old 06-30-2014, 08:44 AM   #11
karim.ouda
Member
 
Registered: Jun 2013
Posts: 41

Rep: Reputation: 3
Have you set password for the user txkk?
Code:
passwd txkk
Enter new UNIX password: 
Retype new UNIX password: 
passwd: password updated successfully
Now try to login again with the user.
Code:
sftp -oPort=2222 txkk@localhost
If you still not able to do it, what is the output of
Code:
ssh -v `whoami`@`hostname`
Enter your password, the account you logged into.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
file transfer from one ftp server to another ftp server divyashree Linux - Newbie 7 02-24-2010 03:48 AM
In plesk , I wish to have a backup cron job, ftp back up file to another ftp server? muskiediver Linux - General 6 07-16-2009 04:13 AM
files not visible in ftp site (but present in the /var/ftp/folder of the server) dongrila Linux - Newbie 2 12-23-2007 11:09 PM
FTP Server Up and running... how do I hide ftp users from local login screen? joe1031 Mandriva 2 03-18-2005 05:24 PM


All times are GMT -5. The time now is 01:17 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration