---
title: "我使用过的Linux命令之ssh - Secure Shell 客户端"
author: "codingstandards"
date: "2011-04-17T12:08:38Z"
tags: ["ITeye", "Linux", "SSH", "SUN", "百度"]
categories: ["操作系统"]
slug: "linux-ssh-secure-shell"
draft: false
lastmod: "2011-04-17T12:08:58Z"
id: 1005494
url: "https://codingstandards.iteye.com/blog/1005494"
---

# 我使用过的Linux命令之ssh - Secure Shell 客户端

本文链接：[http://codingstandards.iteye.com/blog/1005494](/blog/1005494)   （转载请注明出处）

## 用途说明

ssh命令是Linux下常用的远程登录客户端工具，它常用来替代telnet，因为telnet采用明文传输，安全性差，而ssh采用安全传输机制，是远程访问的首选。

 

## 常用方式

格式：ssh &lt;host&gt;

使用SSH远程登录主机&lt;host&gt;，端口为22。用户为当前登录用户。

 

格式：ssh -p &lt;port&gt; &lt;host&gt;

格式：ssh &lt;host&gt; -p &lt;port&gt;

使用SSH远程登录主机&lt;host&gt;，端口为&lt;port&gt;。用户为当前登录用户。

 

格式：ssh -l &lt;user&gt; &lt;host&gt;

格式：ssh &lt;user&gt;@&lt;host&gt;

使用SSH远程登录主机&lt;host&gt;，端口为22。用户为&lt;user&gt;。

 

格式：ssh -p &lt;port&gt; -l &lt;user&gt; &lt;host&gt;

格式：ssh -p &lt;port&gt; &lt;user&gt;@&lt;host&gt;

使用SSH远程登录主机&lt;host&gt;，端口为&lt;port&gt;。用户为&lt;user&gt;。

 

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

sftp -oPort=&lt;port&gt; &lt;host&gt;

使用sftp访问主机&lt;host&gt;，端口为&lt;port&gt;

 

怎样更改sshd的服务端口？

由于OpenSSH也会有安全问题，有时候又不想更新到最新版本，那么常见的提高系统安全性的方法就是修改sshd的服务端口，打开/etc/ssh/sshd\_config，找到#Port 22那行，改成别的端口，比如Port 2622。然后重新加载sshd配置，即执行service sshd reload。

 

## 使用示例

### 示例一

\[root@jfht ~]# 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.  
root@192.168.1.181's password:  
Last login: Sat Mar 26 11:41:14 2011 from cvsbank  
\[root@sunrise root]# exit  
logout

Connection to 192.168.1.181 closed.  
\[root@jfht ~]#

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

Connection to 192.168.1.181 closed.  
\[root@jfht ~]#

### 示例二

\[root@jfht ~]# 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.  
root@192.168.1.186's password:  
\[root@web186 root]# exit  
logout

 

Connection to 192.168.1.186 closed.  
\[root@jfht ~]#

## 问题思考

## 相关资料

【1】Linux公社 Linux服务器使用SSH的命令  
http://www.linuxidc.com/Linux/2008-02/11055.htm  
【2】胡戈戈 Linux SSH命令大全  
http://hugege.com/2009/06/24/linux-ssh/  
【3】百度知道 linux ssh安装  
http://zhidao.baidu.com/question/2518384

 

 

返回 [我使用过的Linux命令系列总目录](/blog/786653)