LINUX913 shell:set ip [lindex $argv 0],\r,send_user,spawn ssh root@ip “cat “

問題

獲取公鑰

[code@samba ~]$ cat pub.sh
#!/bin/usr/expect
set ip "$1"
set password 123456
set timeout 20
spawn ssh root@192.168.235.100:cat ~/.ssh/id_rsa.pub
expect {
"yes/no" {send "yes/r";exp_continue}
"password:" { send "$pass/r" }
timeout {
echo "id _rsa.pub not exsits"
expect "#"
send "ssh-keygen"
expect
}
}
}[code@samba ~]$ vim
[code@samba ~]$ cat pub.sh
#!/bin/expect
set ip "$1"
set password 123456
set timeout 20
spawn ssh root@192.168.235.100:cat ~/.ssh/id_rsa.pub
expect {
"yes/no" {send "yes/r";exp_continue}
"password:" { send "$pass/r" }
timeout {
echo "id _rsa.pub not exsits"
expect "#"
send "ssh-keygen"
expect {
"rsa_pub):" { send "/r"}
"passphrase):" { send "/r" }
"again:" { send "/r" }
}
}
}[code@samba ~]$ ./pub.sh
can't read "1": no such variablewhile executing
"set ip "$1""(file "./pub.sh" line 2)
[code@samba ~]$ ./pub.sh 192.168.235.12
can't read "1": no such variablewhile executing
"set ip "$1""(file "./pub.sh" line 2)

在這里插入圖片描述

[code@samba ~]$ cat pub.sh
#!/bin/expect
set ip "lindex args0"
set password 123456
set timeout 20
spawn ssh root@192.168.235.100:"cat ~/.ssh/id_rsa.pub"
expect {
"yes/no" {send "yes/r";exp_continue}
"password:" { send "$pass/r" }
timeout {
echo "id _rsa.pub not exsits"
expect "#"
send "ssh-keygen"
expect {
"rsa_pub):" { send "/r"}
"passphrase):" { send "/r" }
"again:" { send "/r" }
}
}
}[code@samba ~]$ ./pub.sh
spawn ssh root@192.168.235.100:"cat ~/.ssh/id_rsa.pub"
ssh: Could not resolve hostname 192.168.235.100:"cat: Name or service not known
[code@samba ~]$

在這里插入圖片描述

[code@samba ~]$ cat pub.sh
#!/bin/expect
set ip [lindex $argv 0]
set pass 123456
set timeout 20
spawn ssh root@192.168.235.100 "cat ~/.ssh/id_rsa.pub"
expect {
"yes/no" {send "yes\r";exp_continue}
"password:" { send "$pass\r" }
timeout {
send_user "id _rsa.pub not exsits"
expect "#"
send "ssh-keygen"
expect {
"rsa_pub):" { send "\r"}
"passphrase):" { send "\r" }
"again:" { send "\r" }
}
send_user "id_rsa.pub has been created"
}
send_user "id_rsa.pub is existed"
}[code@samba ~]$ ./pub.sh
spawn ssh root@192.168.235.100 cat ~/.ssh/id_rsa.pub
root@192.168.235.100's password: [code@samba ~]$

在這里插入圖片描述

記錄

    ┌─────────────────────────────────────────────────────────────────┐│                 ? MobaXterm Personal Edition v23.2 ?            ││               (SSH client, X server and network tools)          ││                                                                 ││ ? SSH session to code@192.168.235.10                            ││   ? Direct SSH      :  ?                                        ││   ? SSH compression :  ?                                        ││   ? SSH-browser     :  ?                                        ││   ? X11-forwarding  :  ?  (remote display is forwarded th SSH)  ││                                                                 ││ ? For more info, ctrl+click on help or visit our website.       │└─────────────────────────────────────────────────────────────────┘Last login: Sun Aug 31 14:59:20 2025 from 192.168.235.1
[code@samba ~]$ vim pub.sh
[code@samba ~]$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/home/code/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/code/.ssh/id_rsa.
Your public key has been saved in /home/code/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:ZdIv0j5weH79BKpjSw8Xt8kU/KyWP/CRP+vo8NKhly4 code@samba.w
The key's randomart image is:
+---[RSA 2048]----+
|                 |
|         .   .   |
|        . +   o  |
|         * .   + |
|        S = o + +|
|         B . X O |
|          *.* & +|
|         .oEo=.B.|
|         .ooB=.o*|
+----[SHA256]-----+
[code@samba ~]$ cat pub.sh
#!/bin/usr/expect
set ip "$1"
set password 123456
set timeout 20
spawn ssh root@192.168.235.100:cat ~/.ssh/id_rsa.pub
expect {
"yes/no" {send "yes/r";exp_continue}
"password:" { send "$pass/r" }
timeout {
echo "id _rsa.pub not exsits"
expect "#"
send "ssh-keygen"
expect
}
}
}[code@samba ~]$ vim pub.sh
[code@samba ~]$ vim pub.sh
[code@samba ~]$ cat pub.sh
#!/bin/usr/expect
set ip "$1"
set password 123456
set timeout 20
spawn ssh root@192.168.235.100:cat ~/.ssh/id_rsa.pub
expect {
"yes/no" {send "yes/r";exp_continue}
"password:" { send "$pass/r" }
timeout {
echo "id _rsa.pub not exsits"
expect "#"
send "ssh-keygen"
expect {
"rsa_pub):" { send "/r"}
"phase):" { send "/r" }
"):" { send "/r" }
}
}
}[code@samba ~]$ vim pub.sh
[code@samba ~]$ vim pub.sh
[code@samba ~]$ vim pub.sh
[code@samba ~]$ cat pub.sh
#!/bin/usr/expect
set ip "$1"
set password 123456
set timeout 20
spawn ssh root@192.168.235.100:cat ~/.ssh/id_rsa.pub
expect {
"yes/no" {send "yes/r";exp_continue}
"password:" { send "$pass/r" }
timeout {
echo "id _rsa.pub not exsits"
expect "#"
send "ssh-keygen"
expect {
"rsa_pub):" { send "/r"}
"passphrase):" { send "/r" }
"again:" { send "/r" }
}
}
}[code@samba ~]$ chmod +x pub.sh
[code@samba ~]$ ./pub.sh
-bash: ./pub.sh: /bin/usr/expect: 壞的解釋器: 沒有那個文件或目錄
[code@samba ~]$ vim pub.sh
[code@samba ~]$ which ecpect
/usr/bin/which: no ecpect in (/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/mysql/bin:/home/code/.local/bin:/home/code/bin)
[code@samba ~]$ which expect
/bin/expect
[code@samba ~]$ vim pub.sh
[code@samba ~]$ cat pub.sh
#!/bin/expect
set ip "$1"
set password 123456
set timeout 20
spawn ssh root@192.168.235.100:cat ~/.ssh/id_rsa.pub
expect {
"yes/no" {send "yes/r";exp_continue}
"password:" { send "$pass/r" }
timeout {
echo "id _rsa.pub not exsits"
expect "#"
send "ssh-keygen"
expect {
"rsa_pub):" { send "/r"}
"passphrase):" { send "/r" }
"again:" { send "/r" }
}
}
}[code@samba ~]$ ./pub.sh
can't read "1": no such variablewhile executing
"set ip "$1""(file "./pub.sh" line 2)
[code@samba ~]$ ./pub.sh 192.168.235.12
can't read "1": no such variablewhile executing
"set ip "$1""(file "./pub.sh" line 2)
[code@samba ~]$ vim pub.sh
[code@samba ~]$ cat pub.sh
#!/bin/expect
set ip "lindex args0"
set password 123456
set timeout 20
spawn ssh root@192.168.235.100:cat ~/.ssh/id_rsa.pub
expect {
"yes/no" {send "yes/r";exp_continue}
"password:" { send "$pass/r" }
timeout {
echo "id _rsa.pub not exsits"
expect "#"
send "ssh-keygen"
expect {
"rsa_pub):" { send "/r"}
"passphrase):" { send "/r" }
"again:" { send "/r" }
}
}
}[code@samba ~]$ ./pub.sh
spawn ssh root@192.168.235.100:cat ~/.ssh/id_rsa.pub
ssh: Could not resolve hostname 192.168.235.100:cat: Name or service not known
[code@samba ~]$ vim pub.sh
[code@samba ~]$ cat pub.sh
#!/bin/expect
set ip "lindex args0"
set password 123456
set timeout 20
spawn ssh root@192.168.235.100:"cat ~/.ssh/id_rsa.pub"
expect {
"yes/no" {send "yes/r";exp_continue}
"password:" { send "$pass/r" }
timeout {
echo "id _rsa.pub not exsits"
expect "#"
send "ssh-keygen"
expect {
"rsa_pub):" { send "/r"}
"passphrase):" { send "/r" }
"again:" { send "/r" }
}
}
}[code@samba ~]$ ./pub.sh
spawn ssh root@192.168.235.100:"cat ~/.ssh/id_rsa.pub"
ssh: Could not resolve hostname 192.168.235.100:"cat: Name or service not known
[code@samba ~]$ ./pub.sh 192.168.235.45
spawn ssh root@192.168.235.100:"cat ~/.ssh/id_rsa.pub"
ssh: Could not resolve hostname 192.168.235.100:"cat: Name or service not known
[code@samba ~]$ vim pub.sh
[code@samba ~]$ cat pub.sh
#!/bin/expect
set ip lindex $argv 0
set password 123456
set timeout 20
spawn ssh root@192.168.235.100:"cat ~/.ssh/id_rsa.pub"
expect {
"yes/no" {send "yes/r";exp_continue}
"password:" { send "$pass/r" }
timeout {
echo "id _rsa.pub not exsits"
expect "#"
send "ssh-keygen"
expect {
"rsa_pub):" { send "/r"}
"passphrase):" { send "/r" }
"again:" { send "/r" }
}
}
}[code@samba ~]$ vim pub.sh
[code@samba ~]$ cat pub.sh
#!/bin/expect
set ip [lindex $argv 0]
set pass 123456
set timeout 20
spawn ssh root@192.168.235.100 "cat ~/.ssh/id_rsa.pub"
expect {
"yes/no" {send "yes\r";exp_continue}
"password:" { send "$pass\r" }
timeout {
send_user "id _rsa.pub not exsits"
expect "#"
send "ssh-keygen"
expect {
"rsa_pub):" { send "\r"}
"passphrase):" { send "\r" }
"again:" { send "\r" }
}
}
}[code@samba ~]$ ./pub.sh
spawn ssh root@192.168.235.100 cat ~/.ssh/id_rsa.pub
root@192.168.235.100's password: [code@samba ~]$ vim pub.sh
[code@samba ~]$ cat pub.sh
#!/bin/expect
set ip [lindex $argv 0]
set pass 123456
set timeout 20
spawn ssh root@192.168.235.100 "cat ~/.ssh/id_rsa.pub"
expect {
"yes/no" {send "yes\r";exp_continue}
"password:" { send "$pass\r" }
timeout {
send_user "id _rsa.pub not exsits"
expect "#"
send "ssh-keygen"
expect {
"rsa_pub):" { send "\r"}
"passphrase):" { send "\r" }
"again:" { send "\r" }
}
send_user "id_rsa.pub has been created"
}
send_user "id_rsa.pub is existed"
}[code@samba ~]$ ./pub.sh
spawn ssh root@192.168.235.100 cat ~/.ssh/id_rsa.pub
root@192.168.235.100's password: [code@samba ~]$
[code@samba ~]$ ./pub.sh
spawn ssh root@192.168.235.100 cat ~/.ssh/id_rsa.pub
root@192.168.235.100's password: [code@samba ~]$ vim pub.sh
[code@samba ~]$ cat pub.sh
#!/bin/expect
set ip [lindex $argv 0]
set pass 123456
set timeout 20
spawn ssh root@192.168.235.100 "cat ~/.ssh/id_rsa.pub"
expect {
"yes/no" {send "yes\r";exp_continue}
"password:" { send "$pass\r" }
timeout {
send_user "id _rsa.pub not exsits"
expect "#"
send "ssh-keygen"
expect {
"rsa_pub):" { send "\r"}
"passphrase):" { send "\r" }
"again:" { send "\r" }
}
send_user "id_rsa.pub has been created"
}
send_user "id_rsa.pub is existed"
}
expect eof[code@samba ~]$ ./pub.sh
spawn ssh root@192.168.235.100 cat ~/.ssh/id_rsa.pub
root@192.168.235.100's password:
cat: /root/.ssh/id_rsa.pub: 沒有那個文件或目錄
[code@samba ~]$

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/web/96707.shtml
繁體地址,請注明出處:http://hk.pswp.cn/web/96707.shtml
英文地址,請注明出處:http://en.pswp.cn/web/96707.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

Acwing算法基礎課--鏈表

一、單鏈表 AcWing 826. 單鏈表 代碼 N 100010 idx 0 e [0] * N ne [0] * N head -1def init():global idx,headidx 0head -1def add_head(x):global idx,heade[idx] xne[idx] headhead idxidx 1def delete(k):ne[k] ne[ne[k]]def add_k(k,x):global idxe[idx] …

AI表征了西方的有界,AI+體現了東方的無界

AI表征了西方的有界,AI體現了東方的無界,試圖通過文化差異的視角來對比傳統AI(AI)與增強型或融合型AI(AI)的特征。一、“AI表征了西方的有界”西方的“有界”可以理解為:1、邏輯清晰、結構嚴謹&…

LabVIEW泵輪檢測

?在現代制造業蓬勃發展的浪潮下,汽車行業也迎來了高速發展期。液力變矩器作為實現車輛自動變速的關鍵零件產品,在汽車動力系統中扮演著不可或缺的角色。泵輪作為液力變矩器的核心組成部分,其生產質量直接影響著液力變矩器的性能。因此&#…

RT-DETRv2 中的坐標回歸機制深度解析:為什么用 `sigmoid(inv_sigmoid(ref) + delta)` 而不是除以圖像尺寸?

引言:一個看似簡單的公式,背后藏著工業級設計智慧 在閱讀 RT-DETRv2(Real-Time DETR v2)源碼時,我曾被一行代碼深深震撼: inter_ref_bbox F.sigmoid(bbox_head[i](output) inverse_sigmoid(ref_points_de…

簡單了解一下GraphRAG

傳統RAG的缺點 當我們將一段文本信息以句子分割后,存入到向量數據庫中。用戶提問“老王喜歡吃什么”,這個問題會與向量數據庫中的許多句子關聯性比較強,能返回準確且具體的信息。 但是,若是問題換成“出現了幾次西瓜”&#xff0c…

HTTP 狀態碼背后的邏輯:從請求到響應的完整流程解析(含完整流程圖)

在日常的 Web 開發與 API 調試中,我們經常會遇到各種 HTTP 狀態碼 ——404 Not Found、401 Unauthorized、500 Internal Server Error... 這些數字背后并非隨機出現,而是服務器處理請求過程中不同階段的 "反饋信號"。理解這些狀態碼的觸發邏輯…

Vue:下拉框多選影響行高

目錄 一、 出現場景二、 解決方案 一、 出現場景 在使用el-select增加multiple屬性進行多選時&#xff0c;會出現高度塌陷的情況 二、 解決方案 首先需要在el-select中增加collapse-tags屬性&#xff0c;并在style中增加如下樣式 方案一 <style scoped> ::v-deep .e…

如何在高通躍龍QCS6490 Arm架構上使用Windows 11 IoT企業版?

1.簡介研華已將高通躍龍QCS6490 技術應用于嵌入式模塊、單板電腦和AI攝像頭等各種規格的嵌入式硬件中。QCS6490平臺支持全面的操作系統生態系統&#xff0c;包括Windows、Ubuntu、Yocto和 Android。Windows 11 IoT企業版是微軟新一代的物聯網操作系統&#xff0c;具有更強的安全…

阿里云國際代理:如何利用RDS構建高可用、可擴展的數據庫架構

講下云數據庫RDS案例解析&#xff0c;若在上云或用云過程中有不懂的&#xff0c;可尋云樞國際yunshuguoji助力免卡上云用云。1、RDS MySQL數據庫代理支持讀寫分離、連接保持、就近訪問、事務拆分、連接池、SSL加密等功能&#xff0c;能夠降低主實例負載&#xff0c;提高實例可用…

C++之特殊類設計

文章目錄前言一、 設計一個不能被拷貝的類1. C98 實現方式2. C11 實現方式二、設計一個只能在堆上創建對象的類1. 方法一&#xff1a;析構函數私有&#xff0c;提供destory接口釋放資源2. 方法二&#xff1a;構造函數私有三、 設計一個只能在棧上創建對象的類1. 實現方式四、設…

TupiTube,一款免費開源的 2D 動畫創作工具

TupiTube&#xff0c;一款免費開源的 2D 動畫創作工具 ** ** 功能 ** &#xff1a;開源、免費的 2D 動畫軟件&#xff0c;界面簡單&#xff0c;支持逐幀動畫、剪紙動畫、定格動畫&#xff0c;能導入素材并導出多種視頻和圖片格式&#xff0c;適合兒童、學生和動畫愛好者入門創作…

MoE架構訓練系統設計:專家并行與門控網絡優化策略

點擊 “AladdinEdu&#xff0c;同學們用得起的【H卡】算力平臺”&#xff0c;注冊即送-H卡級別算力&#xff0c;80G大顯存&#xff0c;按量計費&#xff0c;靈活彈性&#xff0c;頂級配置&#xff0c;學生更享專屬優惠。 摘要 混合專家&#xff08;Mixture of Experts&#xf…

使用Python爬蟲,selenium和requests誰更強?

py爬蟲的話&#xff0c;selenium和reqeusts誰更強&#xff0c;selenium是不是能完全取代requests? 答案基本是可以的&#xff0c;selenium適合動態網頁抓取&#xff0c;因為它可以控制瀏覽器去點擊、加載網頁&#xff0c;requests則比較適合靜態網頁采集&#xff0c;它非常輕…

編譯原理-文法壓縮練習

這個任務的目標就是把一個給定的文法變得“干凈”和“高效”&#xff0c;剔除所有無用的部分。根據幻燈片&#xff0c;無用的&#xff08;多余的&#xff09;規則分為兩大類&#xff1a; 不可達規則&#xff1a;規則的“頭”&#xff08;左部非終結符&#xff09;從起始符號出發…

GPU硬件架構和配置的理解

從公司架構理解GPU架構想象一個GPU就像一家大型科技公司&#xff0c;它的任務是處理圖形和計算任務&#xff08;“干活”&#xff09;。硬件概念公司架構比喻作用和特點Platform (平臺)集團公司最大的獨立實體。比如谷歌Alphabet是一個集團公司&#xff0c;它旗下有谷歌、Waymo…

【硬件開發】電源抑制比PSRR

電源抑制比PSRR是電壓輸入量和電壓輸出量的比值&#xff0c;通常用dB來表示。 PSRR這個參數經常和運放&#xff0c;LDO,DCDC變換器有關聯。(2 封私信 / 58 條消息) 電源抑制比(PSRR)的基礎知識 - 知乎

七、卷積神經網絡

目錄 7.1 整體結構 7.2 卷積層 7.2.1 全連接層存在的問題 7.2.2 卷積運算 7.2.3 填充 7.2.5 3維數據的卷積運算 7.2.6 結合方塊思考 7.2.7 批處理 7.3 池化層 7.4 卷積層和池化層的實現 7.4.1 4維數組 7.4.2 基于 im2col的展開 7.4.3 卷積層的實現 7.4.4 池化層的…

加餐加餐!燒烤斗破蒼穹

忽然起了吃燒烤的念頭&#xff0c;便掏出手機點了一堆。不過二十分鐘&#xff0c;外賣小哥便按響了門鈴&#xff0c;手里提著一個方正的紙袋&#xff0c;還冒著熱氣。我將燒烤一一取出&#xff0c;排在茶幾上。肉串油光發亮&#xff0c;韭菜翠綠間點綴著蒜蓉&#xff0c;茄子剖…

搜索引擎收錄網站帶www和不帶www有區別嗎?

這是一個非常常見且重要的問題。簡單直接的回答是&#xff1a;有區別&#xff0c;但對搜索引擎來說&#xff0c;處理得當就不會重復&#xff1b;處理不當則會造成嚴重重復和權重分散。下面我為您詳細解釋一下&#xff0c;并提供正確的處理方法。核心區別&#xff1a;兩個不同的…

AFSim2.9.0學習筆記 —— 2、AFSim的Wizard軟件概述(ArkSIM集成開發環境 (IDE))

&#x1f514; AFSim2.9.0 相關技術、疑難雜癥文章合集&#xff08;掌握后可自封大俠 ?_?&#xff09;&#xff08;記得收藏&#xff0c;持續更新中…&#xff09; 若還沒有下載AFSim2.9.0完整軟件或源碼&#xff0c;請先進入本人另篇文章了解下載。 正文 ??主界面 打開 Ar…