『壹』 關於思科設備SSH登錄中RSA認證的疑問
不是怎樣的。RSA是非對稱的加密演算法,通信的同時雙方都各自產生一對公鑰和私鑰,通信時,使用對方發送過來的公鑰進行加密,然後對方使用自己的私鑰解密數據,這個就是RSA的基本原理了
A要向B發送信息,A和B都要產生一對用於加密和解密的公鑰和私鑰。
2.A的私鑰保密,A的公鑰告訴B;B的私鑰保密,B的公鑰告訴A。
3.A要給B發送信息時,A用B的公鑰加密信息,因為A知道B的公鑰。
4.A將這個消息發給B(已經用B的公鑰加密消息)。
5.B收到這個消息後,B用自己的私鑰解密A的消息。其他所有收到這個報文的人都無法解密,因為只有B才有B的私鑰。
雙方使用RSA通信時雙方都會產生公鑰和密鑰的,不會說一方只產生公鑰,一方只產生私鑰的,這樣的話數據就沒法解密了,
對於演算法我不太懂,具體可參見網路的RSA詞條:http://ke..com/view/7520.htm
和非對稱演算法詞條:http://ke..com/view/1490349.htm
『貳』 如何在 Eclipse 中通過 SSH 密鑰登錄遠程伺服器
安裝了遠程系統資源管理器插件後,已經可以從 Eclipse 中直接登錄遠程伺服器。這里要說的是如何使用現有的密鑰或創建一個新的密鑰,免口令建立 SSH 連接。這樣做的好處是既省事又更安全。
使用現有的密鑰
首先,到菜單 Window/Preferences
選擇 General/Network Connections/SSH2
在這里,可以指定現有的 SSH2 密鑰(必須是OpenSSH的標准)
提示:為了避免出現問題,更改SSH配置後,重新啟動Eclipse。
創建一個新的密鑰 (Key)
點選密鑰管理 (Key Management) 標簽窗口,創建一個新的密鑰。
點擊 Generate RSA Key... 按鈕,生成一個RSA密鑰 。
然後:
添加 comment(inria-gforge-key, 通常可輸入:user@host)
輸入密碼,並確認密碼。(連接伺服器時需輸入一次該密碼。如果是專用電腦,可以不設此密碼)
復制公共密鑰框中的內容,將此公共密鑰粘貼到伺服器上的 ~/.ssh/authorized_keys 文件中去。
點擊保存私鑰 (Save Private Key...) 按鈕,把私鑰保存在一個文件 id_rsa 中。
這樣當再從 Eclipse 登錄遠程伺服器時,就不需要伺服器上的用戶口令了。
『叄』 如何使用RSA密鑰登陸ssh
設置root密碼
1
使用原密鑰登陸遠程主機,默認登陸用戶為ubuntu
得到遠程機IP
如果是aws,在EC2控制台查看一下實例的公有 IP,復制一下
cmd
ssh -i 密鑰 [email protected]
2
空密碼不讓登陸的,所以要給root一個新密碼
su
passwd root
輸入兩次新密碼就可以了
END
修改/etc/ssh/sshd_config
修改
vi /etc/ssh/sshd_config
密碼登陸
PermitRootLogin yes
StrictModes no
PermitEmptyPasswords yes
PasswordAuthentication yes
密鑰登陸
HostKey /etc/ssh/ssh_host_rsa_key
HostKey /etc/ssh/ssh_host_rsa1_key
HostKey /etc/ssh/ssh_host_dsa_key
HostKey /etc/ssh/ssh_host_ecdsa_key
HostKey /etc/ssh/ssh_host_ed25519_key
RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile %h/.ssh/authorized_keys
如果不想一個個改,也可以復制粘貼
全文如下
#/etc/ssh/sshd_config
# Package generated configuration file
# See the sshd_config(5) manpage for details
# What ports, IPs and protocols we listen for
Port 22
# Use these options to restrict which interfaces/protocols sshd will bind to
#ListenAddress ::
#ListenAddress 0.0.0.0
Protocol 2
# HostKeys for protocol version 2
HostKey /etc/ssh/ssh_host_rsa_key
HostKey /etc/ssh/ssh_host_rsa1_key
HostKey /etc/ssh/ssh_host_dsa_key
HostKey /etc/ssh/ssh_host_ecdsa_key
HostKey /etc/ssh/ssh_host_ed25519_key
#Privilege Separation is turned on for security
UsePrivilegeSeparation yes
# Lifetime and size of ephemeral version 1 server key
KeyRegenerationInterval 3600
ServerKeyBits 1024
# Logging
SyslogFacility AUTH
LogLevel INFO
# Authentication:
LoginGraceTime 120
PermitRootLogin yes
StrictModes no
RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile %h/.ssh/authorized_keys
# Don't read the user's ~/.rhosts and ~/.shosts files
IgnoreRhosts yes
# For this to work you will also need host keys in /etc/ssh_known_hosts
RhostsRSAAuthentication no
# similar for protocol version 2
HostbasedAuthentication no
# Uncomment if you don't trust ~/.ssh/known_hosts for RhostsRSAAuthentication
#IgnoreUserKnownHosts yes
# To enable empty passwords, change to yes (NOT RECOMMENDED)
PermitEmptyPasswords yes
# Change to yes to enable challenge-response passwords (beware issues with
# some PAM moles and threads)
no
# Change to no to disable tunnelled clear text passwords
PasswordAuthentication yes
# Kerberos options
#KerberosAuthentication no
#KerberosGetAFSToken no
#KerberosOrLocalPasswd yes
#KerberosTicketCleanup yes
# GSSAPI options
#GSSAPIAuthentication no
#GSSAPICleanupCredentials yes
X11Forwarding yes
X11DisplayOffset 10
PrintMotd no
PrintLastLog yes
TCPKeepAlive yes
#UseLogin no
#MaxStartups 10:30:60
#Banner /etc/issue.net
# Allow client to pass locale environment variables
AcceptEnv LANG LC_*
Subsystem sftp /usr/lib/openssh/sftp-server
# Set this to 'yes' to enable PAM authentication, account processing,
# and session processing. If this is enabled, PAM authentication will
# be allowed through the and
# PasswordAuthentication. Depending on your PAM configuration,
# PAM authentication via may bypass
# the setting of "PermitRootLogin without-password".
# If you just want the PAM account and session checks to run without
# PAM authentication, then enable this but set PasswordAuthentication
# and to 'no'.
UsePAM yes
生成私鑰
ssh-keygen -t dsa /etc/ssh/ssh_host_dsa_key
ssh-keygen -t ecdsa /etc/ssh/ssh_host_ecdsa_key
ssh-keygen -t ed25519 /etc/ssh/ssh_host_ed25519_key
ssh-keygen -t rsa /etc/ssh/ssh_host_rsa_key
ssh-keygen -t rsa1 /etc/ssh/ssh_host_rsa1_key
chmod 600 /etc/ssh/*key
復制公鑰到authorized_keys
cat /etc/ssh/ssh*pub>>/home/ubuntu/.ssh/authorized_keys
cat /home/ubuntu/.ssh/authorized_keys >/root/.ssh/authorized_keys
chmod 644 /root/.ssh/authorized_keys
使用ubuntu的私鑰就可以登陸了
也可以把/etc/ssh/下的key復制粘貼過來
/etc/ssh/ssh_host_dsa_key
/etc/ssh/ssh_host_ecdsa_key
/etc/ssh/ssh_host_ed25519_key
/etc/ssh/ssh_host_rsa_key
重啟遠程機
就可以直接用root登陸了
使用密碼
ssh [email protected]
或者使用密鑰
ssh -i ssh_host_dsa_key root@ip
ssh -i ssh_host_ecdsa_key root@ip
ssh -i ssh_host_ed25519_key root@ip
ssh -i ssh_host_rsa_key root@ip
ssh -i ssh_host_rsa1_key root@ip
『肆』 linux中ssh如何遠程執行一條命令,而且不登錄遠程伺服器
ssh [email protected] 'command ...'
scp [email protected]:/remote/path /local/path
scp /local/path [email protected]:/remote/path
- X forward
ssh -X [email protected]
xcommand ...
- Tunnel / Portforward
ssh -L 1234:remote.machine:4321 [email protected]
ssh -R 1234:local.machine:4321 [email protected]
ssh -L 1234:other.machine:4321 [email protected]
# vi /etc/ssh/sshd_config
PermitRootLogin no
# vi /etc/ssh/sshd_config
RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys
PasswordAuthentication no
# service sshd restart
# su - user1
$ mkdir ~/.ssh 2>/dev/null
$ chmod 700 ~/.ssh
$ touch ~/.ssh/authorized_keys
$ chmod 644 ~/.ssh/authorized_keys
登入端:
$ ssh-keygen -t rsa
(按三下 enter 完成﹔不需設密碼,除非您會用 ssh-agent 。)
$ scp ~/.ssh/id_rsa.pub [email protected]:id_rsa.pub
(若是 windows client, 可用 puttygen.exe 產生 public key,
然後復制到 server 端後修改之, 使其內容成為單一一行.)
回到 server 端:
$ cat ~/id_rsa.pub >> ~/.ssh/authorized_keys
$ rm ~/id_rsa.pub
$ exit
# vi /etc/pam.d/su
auth required /lib/security/$ISA/pam_wheel.so use_uid
# visudo
%wheel ALL=(ALL) ALL
# gpasswd -a user1 wheel
# vi /etc/pam.d/sshd
auth required pam_listfile.so item=user sense=allow file=/etc/ssh_users ōnerr=fail
# echo user1 >> /etc/ssh_users
『伍』 如何在華為交換機中使用ssh登錄
用戶通過 STelnet登錄系統進行ssh登錄。
『陸』 使用RSA/DSA秘鑰認證協議的ssh登陸過程
生成RSA/DSA過程忽略
認證過程:local 發起請求到remote, remote 生成一個隨機數並且使用公鑰加密後發送給local, local接收加密數據然後使用私鑰解密後再發回remote,remote 驗證後判斷是正確的私鑰,進而允許登錄
http://jianjian.blog.51cto.com/35031/123391
『柒』 如何通過ssh遠程登錄linux系統
1、使用用戶名密碼登錄
在命令行中輸入命令:ssh username@ip_address -p port
之後系統會提示輸入密碼,輸入後即可登錄
如果不添加-p選項,則默認是22埠
還可以使用-l選項輸入用戶名:
ssh -l username ip_address -p port
2、使用密鑰登錄(不使用密碼)
首先生成密鑰,在任意目錄下輸入命令:
ssh-keygen -t rsa -P ''
-P表示密碼,-P ''表示空密碼
之後系統會提示輸入生成的密鑰文件的文件名,可以輸入任意名稱,比如id_rsa,回車
系統會在當前目錄下生成id_rsa與id_rsa.pub兩個文件
在根目錄下新建.ssh文件夾,將生成的密鑰文件拷貝過去
mkdir -p ~/.ssh
-p選項表示如果文件夾已經存在則不再新建。
然後將之前生成的兩個文件都拷貝到.ssh文件夾中
cp id_rsa* ~/.ssh/
把公鑰文件id_rsa.pub拷貝到需要登錄的伺服器上
用scp命令
scp -P port ~/.ssh/id_rsa.pub username@ip_address:~
-P表示要登錄伺服器的埠好,不加默認為22。
之後系統會提示輸入密碼,輸入即可完成拷貝
登錄遠程伺服器,在用戶根目錄下新建.ssh文件夾(如果不存在),在其中新建authorized_keys文件(如果不存在),把id_rsa.pub添加到authorized_keys文件中
mkdir -p ~/.ssh
這是在遠程伺服器上新建ssh文件夾
cat id_rsa.pub >> .ssh/authorized_keys
將id_rsa.pub文件添加到authorized_keys文件中(如文件不存在則新建)
注意:要保證.ssh與authorized_keys用戶自己都有寫許可權
退出當前遠程登錄,之後就可以不使用密碼遠程登錄了
『捌』 在windows下如何使用密鑰對遠程登錄伺服器
在企業的生產中相信各位朋友都會使用遠程登錄伺服器,這樣即高效也非常方便,(伺服器在西藏,沒有遠程技術,公司在北京,你只能到西藏與機器相伴,在這里我使用xshell軟體),我們使用ssh 服務登錄伺服器時,如果用用戶名和密碼登錄時(超戶基本都叫root,名字知道了,下面你們懂得),極其不安全。如果使用密鑰對登錄的方式,對咱們的伺服器來說,等於又添加了一道枷鎖,(讓壞人更加難以進入我們的伺服器為所欲為)。那麼我們就來看一下密鑰對如何設置吧
以下過程全程截圖
第一步:進入xshell

『玖』 請教如何用ssh連接遠程伺服器
目前,遠程連接伺服器的類型有以下幾種:
① 文字介面的明文傳輸:Telnet、RSH為主,很少用到。
② 文字介面的加密傳輸:以SSH為主,已經取代了上面的明文傳輸方式。
③ 圖形介面:XDMCP、VNC、XRDP等較為常見。
這篇文章只為實戰,不為普及概念性知識。所以我只講解在工作中最常用到的技術SSH。關於SFTP技術和VNC技術,請查閱我的其他博客。
好,先來看一下SSH的相關技術:
SSH,英文全程是Secure Shell Protocol(安全的殼程序協議)。SSH是現在公司基本上都在使用的一種文字介面的加密傳輸技術,採用的是非對稱秘鑰系統。
對於SSH的原理,你們可以參考我的另外一篇博客,我把鏈接貼在這里:
SSH原理
⑴來吧,我們先來查看一下sshd這個服務(這就是SSH的遠程連接必須開啟的服務,屬於系統自帶),注意,一般這個sshd服務是默認自動開啟的。

注意:切記authorized_keys這個文件的許可權必須是644