SSH關於公鑰認證Permission denied (publickey,gssapi-with-mic的問題
http://h2appy.blog.51cto.com/609721/1112797
ssh使用公鑰授權不通過的問題解決
http://www.2cto.com/os/201206/137286.html
OpenSSH 無密碼訪問配置
http://www.linuxidc.com/Linux/2012-06/62932.htm
Ubuntu下OpenSSH的安裝:
sudo apt-get install openssh-server
一、問題描述
假設 A 為客戶機器,B為目標機;
要達到的目的:
A機器ssh登錄B機器無需輸入密碼;
加密方式選 rsa|dsa均可以,默認dsa
二、具體操作流程
單向登陸的操作過程(能滿足上邊的目的):
1、登錄A機器
2、ssh-keygen -t [rsa|dsa],將會生成密鑰文件和私鑰文件 id_rsa,id_rsa.pub或id_dsa,id_dsa.pub
3、將 .pub 文件復制到B機器的 .ssh 目錄, 並 cat id_dsa.pub > ~/.ssh/authorized_keys
4、大功告成,從A機器登錄B機器的目標賬戶,不再需要密碼了;(直接運行 #ssh 192.168.20.60 )
雙向登陸的操作過程:
1、ssh-keygen做密碼驗證可以使在向對方機器上ssh ,scp不用使用密碼.具體方法如下:
2、兩個節點都執行操作:#ssh-keygen -t rsa
然后全部回車,采用默認值.
3、這樣生成了一對密鑰,存放在用戶目錄的~/.ssh下。
將公鑰考到對方機器的用戶目錄下 ,並將其復制到~/.ssh/authorized_keys中(操作命令:#cat id_dsa.pub >> ~/.ssh/authorized_keys )。
4、設置文件和目錄權限:
設置authorized_keys權限
$ chmod 600 authorized_keys
設置.ssh目錄權限
$ chmod 700 -R .ssh
5、要保證.ssh和authorized_keys都只有用戶自己有寫權限。否則驗證無效。(今天就是遇到這個問題,找了好久問題所在),其實仔細想想,這樣做是為了不會出現系統漏洞。
我從20.60去訪問20.59的時候會提示如下錯誤:
The authenticity of host '192.168.20.59 (192.168.20.59)' can't be established. RSA key fingerprint is 6a:37:c0:e1:09:a4:29:8d:68:d0:ca:21:20:94:be:18. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added '192.168.20.59' (RSA) to the list of known hosts. root@192.168.20.59's password: Permission denied, please try again. root@192.168.20.59's password: Permission denied, please try again. root@192.168.20.59's password: Permission denied (publickey,gssapi-with-mic,password).
三、總結
1、文件和目錄的權限千萬別設置成chmod 777.這個權限太大了,不安全,數字簽名也不支持。
2、生成的rsa/dsa簽名的公鑰是給對方機器使用的,這個公鑰內容還要拷貝到authorized_keys
3、linux之間的訪問直接 ssh 機器ip4、某個機器生成自己的RSA或者DSA的數字簽名,將公鑰給目標機器,然后目標機器接收后設定相關權限(公鑰和authorized_keys權限),這個目標機就能被訪問了!
SSH : Permission denied(publickey,gssapi-with-mic)
http://blog.csdn.net/ashlingr/article/details/7670338
在搭載Hadoop集群過程中,涉及到 配置SSH使用無密碼公鑰認證,遇到了SSH : Permission denied (publickey,gssapi-with-mic)錯誤。現將解決方式記錄下:(由於解決問題的時間和過程過長,有可能會缺少了其中一些步驟,僅供參考)
最終找到的錯誤原因:為了保證sshd_config的配置一致性,在普通用戶下,登錄root,從另外一台機子上將/etc/ssh文件夾中的sshd_config拷貝到這台機子上。但是這樣的操作會改變sshd_config的權限,在ls命令下看到文件變為綠色,與其他配置文件不同,再用“ls -al”查看,sshd_config權限為“-rw-r--r-- ”,將其改為“-rw------- ”,即可。命令:chmod 600 sshd_config。
另外:authorized_keys 的權限為“-rw-------”,即600。
最后,sshd_config配置文件如下:
# $OpenBSD: sshd_config,v 1.73 2005/12/06 22:38:28 reyk Exp $
# This is the sshd server system-wide configuration file. See
# sshd_config(5) for more information.
# This sshd was compiled with PATH=/usr/local/bin:/bin:/usr/bin
# The strategy used for options in the default sshd_config shipped with
# OpenSSH is to specify options with their default value where
# possible, but leave them commented. Uncommented options change a
# default value.
#Port 22
#Protocol 2,1
Protocol 2
#AddressFamily any
#ListenAddress 0.0.0.0
#ListenAddress ::
# HostKey for protocol version 1
#HostKey /etc/ssh/ssh_host_key
# HostKeys for protocol version 2
#HostKey /etc/ssh/ssh_host_rsa_key
#HostKey /etc/ssh/ssh_host_dsa_key
# Lifetime and size of ephemeral version 1 server key
#KeyRegenerationInterval 1h
#ServerKeyBits 768
# Logging
# obsoletes QuietMode and FascistLogging
#SyslogFacility AUTH
SyslogFacility AUTHPRIV
#LogLevel INFO
# Authentication:
#LoginGraceTime 2m
#PermitRootLogin yes
#PermitRootLogin yes
#StrictModes yes
#MaxAuthTries 6
#RSAAuthentication yes
#PubkeyAuthentication yes
#PubkeyAuthentication no
#AuthorizedKeysFile .ssh/authorized_keys
# For this to work you will also need host keys in /etc/ssh/ssh_known_hosts
#RhostsRSAAuthentication no
# similar for protocol version 2
#HostbasedAuthentication no
# Change to yes if you don't trust ~/.ssh/known_hosts for
# RhostsRSAAuthentication and HostbasedAuthentication
#IgnoreUserKnownHosts no
# Don't read the user's ~/.rhosts and ~/.shosts files
#IgnoreRhosts yes
# To disable tunneled clear text passwords, change to no here!
#PasswordAuthentication yes
#PermitEmptyPasswords no
#PasswordAuthentication yes
PasswordAuthentication no
AuthorizedKeysFile .ssh/authorized_keys
# Change to no to disable s/key passwords
#ChallengeResponseAuthentication yes
ChallengeResponseAuthentication no
# Kerberos options
#KerberosAuthentication no
#KerberosOrLocalPasswd yes
#KerberosTicketCleanup yes
#KerberosGetAFSToken no
# GSSAPI options
#GSSAPIAuthentication no
GSSAPIAuthentication yes
#GSSAPICleanupCredentials yes
GSSAPICleanupCredentials yes
# Set this to 'yes' to enable PAM authentication, account processing,
# and session processing. If this is enabled, PAM authentication will
# be allowed through the ChallengeResponseAuthentication mechanism.
# Depending on your PAM configuration, this may bypass the setting of
# PasswordAuthentication, PermitEmptyPasswords, and
# "PermitRootLogin without-password". If you just want the PAM account and
# session checks to run without PAM authentication, then enable this but set
# ChallengeResponseAuthentication=no
#UsePAM no
UsePAM yes
# Accept locale-related environment variables
AcceptEnv LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES
AcceptEnv LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT
AcceptEnv LC_IDENTIFICATION LC_ALL
#AllowTcpForwarding yes
#GatewayPorts no
#X11Forwarding no
X11Forwarding yes
#X11DisplayOffset 10
#X11UseLocalhost yes
#PrintMotd yes
#PrintLastLog yes
#TCPKeepAlive yes
#UseLogin no
#UsePrivilegeSeparation yes
#PermitUserEnvironment no
#Compression delayed
#ClientAliveInterval 0
#ClientAliveCountMax 3
#ShowPatchLevel no
#UseDNS yes
#PidFile /var/run/sshd.pid
#MaxStartups 10
#PermitTunnel no
#ChrootDirectory none
# no default banner path
#Banner /some/path
# override default of no subsystems
Subsystem sftp /usr/libexec/openssh/sftp-server
SSH 登錄是錯誤:Permission denied (publickey,gssapi-with-mic)
http://www.oschina.net/question/54100_28922
$ ssh root@192.168.xx.xx
Permission denied (publickey,gssapi-with-mic).
報了這么個錯,原因是我上次做測試時修改了/etc/ssh/sshd_config 中的"PasswordAuthentication"參數值為"no",修改回"yes",重啟sshd服務即可。
git@osc 上傳公鑰總是失敗的問題
http://my.oschina.net/230/blog/145883
復制公鑰到http://git.oschina.net/keys里時提示:
- Key can't be fingerprinted
或者提示:
- Key 是無效的
這都是文本格式問題,因為我都是在終端使用命令:
cat ~/.ssh/id_rsa.pub
獲取然后復制過去的,即使去掉了復制過程中而外的空格,還是提示上訴錯誤。
另外在文本編輯器中打開,然后c-a,c-c,復制過去就可以了,,
:-)
筆記~SSH無需密碼密鑰登錄,centos 5.5 下成功
http://my.oschina.net/emptytimespace/blog/79173
SSH公鑰無密碼認證
http://my.oschina.net/heartdong/blog/135374
1)在master主機上生成密碼對
1 |
ssh-keygen –t rsa –P '' |
確認一路回車,命令默認會在用戶主目錄下生成.ssh目錄,你們有兩 密鑰對文件:id_rsa和id_rsa.pub
1 |
[master@hadoop ~]$ ll .ssh/ |
2 |
-rw-------. 1 master master 1675 Jun 3 00:28 id_rsa |
3 |
-rw-r--r--. 1 master master 402 Jun 3 00:28 id_rsa.pub |
接着在master節點上做如下配置,把id_rsa.pub追加到授權的key里面去。
1 |
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys |
本以為這么就可以搞定了的,發現輸入命令ssh localhost還是要密碼。
搗鼓了半天,終於還是被我找到了原因
找到服務器修改SSH配置文件"/etc/ssh/sshd_config",修改如下內容(去掉前面的注釋)
1 |
RSAAuthentication yes # 啟用 RSA 認證 |
2 |
PubkeyAuthentication yes # 啟用公鑰私鑰配對認證方式 |
3 |
AuthorizedKeysFile .ssh/authorized_keys # 公鑰文件路徑(和上面生成的文件同) |
設置完之后記得 重啟SSH服務
1 |
service sshd restart |
重新驗證ssh localhost,無密碼登陸成功
配置遠程登陸其他機器也是同一個原理,只需把本機生成的id_rsa.pub上傳到其他服務器做同樣操作即可。
ssh: permission denied (publickey)
http://www.blogjava.net/dongbule/archive/2011/01/04/342275.html
ssh出現permission denied (publickey)問題:
修改/etc/ssh/sshd-config文件.
將其中的PermitRootLogin no修改為yes
PubkeyAuthentication yes修改為no
AuthorizedKeysFile .ssh/authorized_keys前面加上#屏蔽掉,
PasswordAuthentication no修改為yes就可以了。
vi /etc/ssh/sshd-config (詳細說說sshd-config的配置解釋)
Port 22
Protocol 2
PermitRootLogin no
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys
#CACertificateFile /etc/ssh/ca/ca.cert
PasswordAuthentication no
PermitEmptyPasswords no
PrintMotd no
ChallengeResponseAuthentication no
UseDNS no
ClientAliveInterval 60
Port 22 # SSH 預設使用 22 這個 port,您也可以使用多的 port !亦即重復使用 port 這個設定項目即可!
Protocol 2 # 選擇的 SSH 協議版本,可以是 1 也可以是 2 ,如果要同時支持兩者,就必須要使用 2,1 這個分隔了
PermitRootLogin no # 是否允許 root 登入!預設是允許的,但是建議設定成 no!
PubkeyAuthentication yes # 是否允許 Public Key
AuthorizedKeysFile .ssh/authorized_keys # 上面這個在設定若要使用不需要密碼登入的賬號時,那么那個賬號的存放檔案所在檔名!
PasswordAuthentication no # 是否需要密碼的驗證
PermitEmptyPasswords no # 若上面那一項如果設定為 yes 的話,這一項就最好設定為 no ,這個項目在是否允許以空的密碼登入!當然不許!
PrintMotd no # 登入后是否顯示出一些信息呢?例如上次登入的時間、地點等
ChallengeResponseAuthentication no # 是否啟用其它的 PAM 模塊!啟用這個模塊將會導致 PasswordAuthentication 設定失效!
UseDNS no
ClientAliveInterval 60
ssh使用公鑰授權不通過的問題解決
http://www.2cto.com/os/201206/137286.html
