之前的文章http://blog.csdn.net/qq_35263061/article/details/59490820介紹關於修改ssh端口和禁止root遠程登錄。修改端口和禁止root遠程登錄後,程序員告訴我無法直接用root賬戶登錄winscp,可是普通用戶還沒有傳文件到制定目錄的權限。可能大家也都遇到過這樣的問題,遠程連接可以su root。但是winscp不可以su。今天我們來看看怎麼使普通用戶可以用winscp傳文件。(可以su root使用root權限)
- 1、看你的sftp位置
[root@cxm ~]# cat /etc/ssh/sshd_config | grep sftp
Subsystem sftp /usr/libexec/openssh/sftp-server #位置
- 2、修改sudo文件,給普通用戶權限
[root@cxm ~]# vim /etc/sudoers
## Allow root to run any commands anywhere
root ALL=(ALL) ALL
cxm ALL=NOPASSWD /usr/libexec/openssh/sftp-server#加入此行(cxm爲普通用戶的用戶名,ALL=NOPASSWD爲權限,/usr/libexec/openssh/sftp-server爲sftp路徑)
#Defaults requiretty #註釋掉此行,不然會報錯
- 3、然後source下修改的文件,使其立即生效。(必須要做不然報錯)
[root@cxm ~]# source /etc/sudoers
- 4、連接winscp
- 之後你就可以輕鬆的拖拽文件了。