A sftp request have to be met for a project. To setup a sftp ASAP in current environment , i found a linux server running CentOS and plan to deploy sftp server with OpenSSH. The detailed procedures are following:
1. Generate a pair of keys.public & private key for sftp user. The public key will be saved a certain directory of sftp users just like /home/somebody/.ssh/authorized_keys and the private key will be copy to workstation where running sftp client.
(1).ssh-keygen -t rsa
(2)change id_rsa.pub to authorized_keys and save to .ssh directory which created under user home directory and have to grant sufficient privilege just like chmod 600
2. Modify sshd_config file to power sftp function
(1) enable public key authentication method
(2)disable password authentication methodPort 22
************************************************************************
Protocol 2
HostKey /etc/ssh/ssh_host_rsa_key
HostKey /etc/ssh/ssh_host_dsa_key
KeyRegenerationInterval 3600
ServerKeyBits 768
SyslogFacility AUTH
LogLevel INFO
LoginGraceTime 600
PermitRootLogin yes
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys
RhostsAuthentication no
IgnoreRhosts yes
HostbasedAuthentication no
PasswordAuthentication no
PermitEmptyPasswords no
ChallengeResponseAuthentication no
MaxStartups 20
Subsystem sftp /usr/libexec/openssh/sftp-server
*****************************************************************
3. import private key for client tool which support sftp (i.e flashxp 4.0) and try to connect to sftp server.
转载于:https://blog.51cto.com/itseeker/457678