Linux上安裝使用SSH(ubuntu)
阿新 • • 發佈:2019-01-04
Ubuntu安裝使用SSH
ubuntu預設並沒有安裝ssh服務,如果通過ssh連結ubuntu,需要自己手動安裝ssh-server。判斷是否安裝ssh服務,可以通過如下命令進行:
[email protected]:~$ ssh localhost
ssh: connect to host localhost port 22: Connection refused
如上所示,表示沒有還沒有安裝,可以通過apt安裝,命令如下:
[email protected]:~$ sudo apt-get install openssh-server
系統將自動進行安裝,安裝完成以後,先啟動服務:
[email protected]:~$ sudo /etc/init.d/ssh start
啟動後,可以通過如下命令檢視服務是否正確啟動
[email protected]:~$ ps -e|grep ssh
6212 ? 00:00:00 sshd
如上表示啟動ok。注意,ssh預設的埠是22,可以更改埠,更改後先stop,
然後start就可以了。改配置在/etc/ssh/sshd_config下,如下所示。
[email protected]:~$ vi /etc/ssh/sshd_config
# Package generated configuration file
# See the sshd(8) manpage for details
# What ports, IPs and protocols we listen for
Port 22
最後,應該是連線的時候了。請看如下命令:
[email protected]:~$ ssh [email protected]
ubuntu預設並沒有安裝ssh服務,如果通過ssh連結ubuntu,需要自己手動安裝ssh-server。判斷是否安裝ssh服務,可以通過如下命令進行:
[email protected]:~$ ssh localhost
ssh: connect to host localhost port 22: Connection refused
如上所示,表示沒有還沒有安裝,可以通過apt安裝,命令如下:
[email protected]:~$ sudo apt-get install openssh-server
系統將自動進行安裝,安裝完成以後,先啟動服務:
啟動後,可以通過如下命令檢視服務是否正確啟動
[email protected]:~$ ps -e|grep ssh
6212 ? 00:00:00 sshd
如上表示啟動ok。注意,ssh預設的埠是22,可以更改埠,更改後先stop,
然後start就可以了。改配置在/etc/ssh/sshd_config下,如下所示。
[email protected]:~$ vi /etc/ssh/sshd_config
# Package generated configuration file
# See the sshd(8) manpage for details
# What ports, IPs and protocols we listen for
Port 22
最後,應該是連線的時候了。請看如下命令: