Windos + GitBash實現免密遠端登入Ubuntu
阿新 • 來源:網路 • 發佈:2021-02-07
Windows下安裝git後,會有一個自帶的gitbash,使用gitbash遠端登入ububtu
-
gitbash上進行的操作
ssh-keygen -t rsa # 提示輸入東西的時候,連續按3次enter 就好,在~/.ssh目錄 下生成了id_rsa 和id_rsa.pub兩個檔案,後者上傳至目標伺服器 ssh-copy-id [email protected] # server_user是伺服器使用者名稱,ipAddr是IP地址 -
ubuntu上進行的操作
# 找到 /etc/ssh/sshd_config 這個檔案,以下幾行取消註釋。 #RSAAuthentication yes #PubkeyAuthentication yes #AuthorizedKeysFile .ssh/authorized_keys # 第2個可能找不到,沒關係 sudo service ssh restart -
實現ssh別名登入
# windows上編輯 C:\Users\${userName}\.ssh\config,內容如下: # Host alias(別名) # HostName ip_address ip地址 # User user ssh登入時使用的使用者 # 下面是一個例子 Host xiaoyao HostName 192.168.1.7 User xiaoyao #################### # 配置後之後可以執行如下操作也可完成登入 $ ssh xiaoyao Welcome to Ubuntu 20.10 (GNU/Linux 5.8.0-41-generic x86_64) * Documentation: https://help.ubuntu.com * Management: https://landscape.canonical.com * Support: https://ubuntu.com/advantage 0 updates can be installed immediately. 0 of these updates are security updates. Last login: Sat Feb 6 10:01:07 2021 from 192.168.1.2 [email protected]:~$ logout Connection to 192.168.1.7 closed. -
解決 直接使用cmd執行 ssh 報錯 “Bad owner or permissions”
使用gitbash自帶的ssh即可,通過修改環境變數實現。
