- 工信部備案號 滇ICP備05000110號-1
- 滇公安備案 滇53010302000111
- 增值電信業務經營許可證 B1.B2-20181647、滇B1.B2-20190004
- 云南互聯網協會理事單位
- 安全聯盟認證網站身份V標記
- 域名注冊服務機構許可:滇D3-20230001
- 代理域名注冊服務機構:新網數碼
1.安裝ssh
apt-get install openssh-server
2.備份ssh的配置文件
sudo cp /etc/ssh/sshd_config /etc/ssh/sshd_config.bak
3.新裝的ssh需要修改配置文件
vi /etc/ssh/sshd_config
配置文件修改這幾處地方
Port = 22 # 默認是22端口,如果和windows端口沖突或你想換成其他的否則不用動
#ListenAddress 0.0.0.0 # 如果需要指定監聽的IP則去除最左側的井號,并配置對應IP,默認即監聽PC所有IP
PermitRootLogin no # 如果你需要用 root 直接登錄系統則此處改為 yes
PasswordAuthentication no # 將 no 改為 yes 表示使用帳號密碼方式登錄
4.啟動ssh
service ssh start # * Starting OpenBSD Secure Shell server sshd
# 或者
/etc/init.d/ssh start # * Starting OpenBSD Secure Shell server sshd
如果提示錯誤信息中包含could not load host key 則需要重新生成 key
sudo rm /etc/ssh/ssh*key # 先移除舊的key
dpkg-reconfigure openssh-server
生成之后需要重啟SSH服務使新的密鑰生效:
service ssh restart # * Restarting OpenBSD Secure Shell server sshd
# 或者
/etc/init.d/ssh restart # * Restarting OpenBSD Secure Shell server sshd
啟動、停止和重啟ssh的命令如下
/etc/init.d/ssh start # * Starting OpenBSD Secure Shell server sshd
/etc/init.d/ssh stop # * Stopping OpenBSD Secure Shell server sshd
/etc/init.d/ssh restart # * Restarting OpenBSD Secure Shell server sshd
5.查看服務狀態
service ssh status
# * sshd is running 顯示此內容則表示啟動正常
6.查看ssh是否啟動
ps -e | grep ssh
如果ssh已經啟動則會提示
469 ? 00:00:00 sshd
7.設置ssh開機自啟動
sudo systemctl enable ssh #說明:sudo是提升權限,systemctl是服務管理器,enable是systemctl的參數,表示啟用開機自動運行,ssh是要設置的服務名稱。
注:如果要設置開機禁止啟動則
sudo systemctl disable ssh #說明:sudo是提升權限,systemctl是服務管理器,disable是systemctl的參數,表示禁止開機運行,ssh是要設置的服務名稱。
提交成功!非常感謝您的反饋,我們會繼續努力做到更好!
這條文檔是否有幫助解決問題?
售前咨詢
售后咨詢
備案咨詢
二維碼
TOP