Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password)

sftp -b batchfile username@remote_host

报错:Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password)

因为SSH不能访问你的authorized_keys,所以必需先认证然后才能访问

remote_host,root登陆

# mkdir /etc/ssh/<username> 

# cp /home/<username>/.ssh/authorized_keys /etc/ssh/<username>/

# chmod 755 /etc/ssh/<username>

# chmod 600 /etc/ssh/<username>/authorized_keys

# chown -R username:username /etc/ssh/<username> 

3. 编辑配置文件/etc/ssh/sshd_config并添加下列内容

# vi /etc/ssh/sshd_config

AuthorizedKeysFile    /etc/ssh/%u/authorized_keys

4. 重启SSH

# /etc/init.d/sshd restart

原文地址:https://www.cnblogs.com/jxterminator/p/4105545.html