歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux編程 >> SHELL編程 >> Linux命令之ssh - Secure Shell 客戶端

Linux命令之ssh - Secure Shell 客戶端

日期:2017/2/28 16:17:18   编辑:SHELL編程

用途說明
ssh命令是Linux下常用的遠程登錄客戶端工具,它常用來替代telnet,因為telnet采用明文傳輸,安全性差,而ssh采用安全傳輸機制,是遠程訪問的首選。

常用方式
格式:ssh <host>

使用SSH遠程登錄主機<host>,端口為22。用戶為當前登錄用戶。

格式:ssh -p <port> <host>

格式:ssh <host> -p <port>

使用SSH遠程登錄主機<host>,端口為<port>。用戶為當前登錄用戶。

格式:ssh -l <user> <host>

格式:ssh <user>@<host>

使用SSH遠程登錄主機<host>,端口為22。用戶為<user>。

格式:ssh -p <port> -l <user> <host>

格式:ssh -p <port> <user>@<host>

使用SSH遠程登錄主機<host>,端口為<port>。用戶為<user>。

要注意的是sftp工具的端口指定方式是

sftp -oPort=<port> <host>

使用sftp訪問主機<host>,端口為<port>

怎樣更改sshd的服務端口?

由於OpenSSH也會有安全問題,有時候又不想更新到最新版本,那麼常見的提高系統安全性的方法就是修改sshd的服務端口,打開/etc/ssh/sshd_config,找到#Port 22那行,改成別的端口,比如Port 2622。然後重新加載sshd配置,即執行service sshd reload。

使用示例
示例一
[[email protected] ~]# ssh 192.168.1.181
The authenticity of host '192.168.1.181 (192.168.1.181)' can't be established.
RSA key fingerprint is 5e:bf:a3:bf:a5:40:58:02:ce:00:55:53:50:f8:73:46.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.1.181' (RSA) to the list of known hosts.
[email protected]'s password:
Last login: Sat Mar 26 11:41:14 2011 from cvsbank
[root@linuxidc root]# exit
logout

Connection to 192.168.1.181 closed.
[[email protected] ~]#

[[email protected] ~]# ssh 192.168.1.181
[email protected]'s password:
Last login: Sun Apr 17 11:45:54 2011 from 192.168.1.191
[root@linuxidc root]# exit
logout

Connection to 192.168.1.181 closed.
[[email protected] ~]#

示例二
[[email protected] ~]# ssh -p 18622 192.168.1.186
The authenticity of host '192.168.1.186 (192.168.1.186)' can't be established.
RSA key fingerprint is 70:99:59:b2:f3:55:f9:fd:7d:a8:3b:76:d0:63:f7:32.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.1.186' (RSA) to the list of known hosts.
[email protected]'s password:
[root@web186 root]# exit
logout

Connection to 192.168.1.186 closed.
[[email protected] ~]#

Copyright © Linux教程網 All Rights Reserved