問題一 : /etc/ssh/ssh_config line 57: Unsupported option "gssapiauthentication"
ssh升級之后登陸遠程服務器的時候出現如下報錯
/etc/ssh/ssh_config line 57: Unsupported option "gssapiauthentication"
客戶端:
找到/etc/ssh/ssh_config配置文件的第57行
GSSAPIAuthentication yes
把這一行注釋掉就行了
服務端:
注釋sshd_config的以下參數:
#GSSAPIAuthentication yes
#GSSAPICleanupCredentials yes
#UsePAM yes
服務端改配置需要重啟sshd服務
問題二 : su命令不能用.
使用su命令不成功,無在目標機器上通過一個普通用戶su切換為root執行相關命令
錯誤如下:
ansible Timeout (12s) waiting for privilege escalation prompt
我碰到的原因是因為ansible管理的客戶端上面sshd配置文件設置有誤,我直接從沒問題的主機拷貝的sshd_config文件到問題主機上解決的,網上說的一種修改ansible.cfg的超時時間,不適合我當時碰到的情況
問題三 : 文件句柄數設置不成功
[root@cpoc-2 ssh]# cat /etc/security/limits.conf |grep -v ^#|grep -v ^$ * soft core 0 * hard core 0 * soft nproc 65535 * hard nproc 65535 * soft nofile 655350 * hard nofile 655350 * soft memlock 96 * hard memlock 96 [root@cpoc-2 ssh]# cat /etc/security/limits.d/20-nproc.conf |grep -v ^#|grep -v ^$ * soft nproc 4096 root soft nproc unlimited
然后普通用戶ssh登陸之后查看 ulimit -a
[xuweiyuan@cpoc-2 ~]$ ulimit -n 1024 [xuweiyuan@cpoc-2 ~]$ ulimit -u 4096
ssh不支持pam,查找原因是編譯openssh的時候沒有支持pam,也就是 --with-pam
./configure --prefix=/usr --sysconfdir=/etc/ssh --with-md5-passwords --with-zlib --with-pam make -j4 && make instal
重新編譯安裝,調整sshd_config文件,重啟服務之后,登陸服務器的時候,輸入正確的密碼,然后出現如下報錯
密碼錯誤,是因為UsePAM yes
查看/etc/pam.d目錄,沒有發現sshd,所以重新寫了一個文件
vim /etc/pam.d/sshd #%PAM-1.0 auth required pam_sepermit.so auth substack password-auth auth include postlogin # Used with polkit to reauthorize users in remote sessions -auth optional pam_reauthorize.so prepare account required pam_nologin.so account include password-auth password include password-auth # pam_selinux.so close should be the first session rule session required pam_selinux.so close session required pam_loginuid.so # pam_selinux.so open should only be followed by sessions to be executed in the user context session required pam_selinux.so open env_params session required pam_namespace.so session optional pam_keyinit.so force revoke session include password-auth session include postlogin # Used with polkit to reauthorize users in remote sessions -session optional pam_reauthorize.so prepare
重啟sshd服務,再次登陸沒有問題,而且查看 ulimit -a
[xuweiyuan@cpoc-2 ~]$ ulimit -n 655350 [xuweiyuan@cpoc-2 ~]$ ulimit -u 4096
已經和/etc/security/limits.conf文件配置的一樣了
所以說卸載系統自帶的openssh之前,最好是備份一下/etc/pam.d/sshd
cp /etc/pam.d/sshd{,.old}
編譯完之后 ,查看/etc/pam.d如果沒有sshd文件,就恢復備份
問題四 : [WARNING]: sftp transfer mechanism failed on [172.30.241.149]. Use ANSIBLE_DEBUG=1 to see detailed information
錯誤信息如下:
[root@cpoc-1 xuweiyuan]# ansible all -b --become-method=su -m shell -a "whoami" [WARNING]: sftp transfer mechanism failed on [172.30.241.149]. Use ANSIBLE_DEBUG=1 to see detailed information 172.30.241.150 | CHANGED | rc=0 >> root 172.30.241.149 | CHANGED | rc=0 >> root
查看sshd_config文件
cat sshd_config|grep sftp
Subsystem sftp /usr/libexec/openssh/sftp-server ll /usr/libexec/openssh/sftp-server
ls: cannot access /usr/libexec/openssh/sftp-server: No such file or directory
查找 sftp-server
ll /usr/libexec/sftp-server
-rwxr-xr-x 1 root root 112800 Jul 26 15:47 /usr/libexec/sftp-server
然后修改配置文件
Subsystem sftp /usr/libexec/openssh/sftp-server
改成
Subsystem sftp /usr/libexec/sftp-server
重啟服務systemctl restart sshd ,重新執行命令,查看結果
[root@cpoc-1 xuweiyuan]# ansible all -b --become-method=su -m shell -a "whoami" 172.30.241.150 | CHANGED | rc=0 >> root 172.30.241.149 | CHANGED | rc=0 >> root
啦