對於一些不能訪問internet的伺服器,需要通過離線安裝軟體。通過製作ubuntu本地源,可以實現通過apt install來離線安裝軟體。
以安裝expect為例:
a. mkdir packages
b . cd packages
方法一:
apt-get download expect && apt-cache depends -i expect | awk '/depends:/ ' | xargs apt-get download
若碰到類似下面的錯誤
w: download is performed unsandboxed as root as file '/home/dongsongz/local/packages/cdebconf_0.213ubuntu1_amd64.deb' couldn't be accessed by user '_apt'. - pkgacquire::run (13: permission denied)
執行chown _apt:root ../packages/
方法二:
mkdir -p /root/packages
mkdir -p /root/packages/partial
apt-get -o dir::cache::archives="/root/packages/" -d --reinstall install expect
c. dpkg-scanpackages . | gzip -9c > packages.gz
command 'dpkg-scanpackages' not found, but can be installed with:
apt install dpkg-dev
d. tar -zcf ubuntu_local_package.tar.gz packages/
2.將ubuntu_local_package.tar.gz拷貝到目標機器進行離線安裝
tar zxf ubuntu_local_package.tar.gz -c localpackages/
cp /etc/apt/sources.list /etc/apt/sources.list.bak
echo "deb [trusted=yes] file:///home/dongsongz/local/localpackages/packages/ ./" > /etc/apt/sources.list
/home/dongsongz/local/localpackages/packages/替換為實際解壓的路徑
apt clean all
apt update
apt install -y tcl tk expect
3.安裝完畢,測試一下
#/usr/bin/expect
spawn ssh [email protected]
expect
} "*password:"
}expect "*#"
send "ls"
interact
expect -f login.sh
spawn ssh [email protected]
[email protected]'s password:
last login: tue jul 21 19:18:36 2020 from ............
[root@cdh1 ~]#
登入成功~
Ubuntu18 04 離線本地源的製作
環境 一台能上網的ubuntu電腦,一台不能上網的ubuntu電腦。ubuntu版本都是18.04lts。目標 將能上網的ubuntu電腦安裝的軟體製作成源,通過u盤拷貝給內網電腦,內網電腦根據此離線源通過apt安裝軟體。為什麼不直接拷貝deb安裝呢?因為有些軟體安裝依賴的包比較多。遇到的問題 從u...
ubuntu製作本地源
先在有網路的伺服器上面進行apt get install安裝 然後製作本地源 將本地源拷貝到沒有網路的伺服器上,然後在那台機器上設定sourcelist指向這個本地源,此時在那台沒有網路的伺服器上也可以執行apt get install安裝了。下面給出可行且實用的部分本地源製作步驟 mkdir pa...
ubuntu本地源製作
cd mkdir soft cp r v soft r是遞迴呼叫 v是顯示 是拷貝所有檔案 到 soft目錄下 cd soft sudo dpkg scanpackages soft dev null gzip soft packages.gz掃面當前目錄的包,什麼也輸出,然後將包打包到soft p...