/ 中存储网

告诉你Ubuntu下安装OpenSSH Server并在客户端远程连接Ubuntu的方

2015-02-05 00:00:00 来源:中存储网

Ubuntu 下安装 OpenSSH Server有三种方法:

方法一 (最麻烦的方式):手动安装

我个人不推荐这种方式,因为OpenSSH Server需要很多的依赖包,一旦手动安装起来差不多麻烦。

方法二 (推荐 ):命令行安装

只需要一条命令:

sudo apt-get install openssh-server

随后,Ubuntu 会自动下载并安装 openssh server,并一并解决所有的依赖关系。

方法三 :通过 Ubuntu Software Center 安装

首先进入 Ubuntu Software Center,然后在搜索栏里输入“openssh-server”;

随后会看到搜索结果里有openssh-server;

接着点击“Install”就可安装。

接下来介绍在Windows系统下远程连接Linux,我用的是Putty远程连接工具:

1)首先要确保你的Linux可以联网,并启动openssh server。

sudo /etc/init.d/ssh start 

##sudo /etc/init.d/ssh restart

2)然后通过接下来的Linux命令查看IP地址:

ifconfig

3)然后在客户端启动Putty 输入要远程连接的Linux IP地址,端口号默认为 22,就可远程连接到Linux。

secure shell (SSH) server, for secure access from remote machines

这是 OpenSSH 的移植版本,实现 IETF secsh 工作组制定的安全 Shell 协议的 自由软件。

Ssh (Secure Shell) is a program for logging into a remote machine and for executing commands on a remote machine. It provides secure encrypted communications between two untrusted hosts over an insecure network. X11 connections and arbitrary TCP/IP ports can also be forwarded over the secure channel. It can be used to provide applications with a secure communication channel.

This package provides the sshd server.

在某些国家使用未经授权的加密方法是违法的。

sshd replaces the insecure rshd program, which is obsolete for most purposes.
其他与 openssh-server 有关的软件包

依赖 推荐 建议

dep: adduser (>= 3.9)
添加、删除用户和组

dep: debconf (>= 1.2.0)
Debian 配置管理系统
或者 debconf-2.0
本虚包由这些包填实: cdebconf, cdebconf-udeb, debconf

dep: dpkg (>= 1.9.0)
Debian软件包管理系统

dep: libc6 (>= 2.8)
Embedded GNU C Library: Shared libraries
同时作为一个虚包由这些包填实: libc6-udeb

dep: libcomerr2 (>= 1.01)
通用错误描述库

dep: libgssapi-krb5-2 (>= 1.7dfsg~beta1)
MIT Kerberos runtime libraries - krb5 GSS-API Mechanism

dep: libkrb5-3 (>= 1.6.dfsg.2)
MIT Kerberos runtime libraries

dep: libpam-modules (>= 0.72-9)
用于 PAM 的可插入的认证模块

dep: libpam-runtime (>= 0.76-14)
PAM 库的运行时支持包

dep: libpam0g (>= 0.99.7.1)
嵌入式认证模块库, 包含了Linux-PAM的

dep: libselinux1 (>= 1.32)
SELinux runtime shared libraries

dep: libssl0.9.8 (>= 0.9.8k-1)
SSL 共享库

dep: libwrap0 (>= 7.6-4~)
Wietse Venema 的 TCP 包装库

dep: lsb-base (>= 3.2-13)
Linux Standard Base 4.0 init script functionality

dep: openssh-client (= 1:5.3p1-3Ubuntu3)
secure shell (SSH) client, for secure access to remote machines

dep: procps
/proc 文件系统工具

dep: zlib1g (>= 1:1.1.4)
压缩库-运行时

rec: xauth
X authentication utility

sug: molly-guard
protects machines from accidental shutdowns/reboots

sug: openssh-blacklist
list of default blacklisted OpenSSH RSA and DSA keys

sug: openssh-blacklist-extra
list of non-default blacklisted OpenSSH RSA and DSA keys

sug: rssh
Restricted shell allowing scp, sftp, cvs, svn, rsync or rdist

sug: ssh-askpass
under X, asks user for a passphrase for ssh-add
同时作为一个虚包由这些包填实: gtk-led-askpass, ksshaskpass, ssh-askpass-fullscreen, ssh-askpass-gnome

sug: ufw
program for managing a Netfilter firewall

下载 openssh-server
下载可用于所有硬件架构的硬件架构 软件包大小 安装后大小 文件
amd64  297.0 kB  796 kB  [文件列表:http://packages.ubuntu.com/lucid/amd64/openssh-server/filelist]
i386  278.0 kB  760 kB  [文件列表:http://packages.ubuntu.com/lucid/i386/openssh-server/filelist]

OpenSSH Server
Introduction

This section of the Ubuntu Server Guide introduces a powerful collection of tools for the remote control of networked computers and transfer of data between networked computers, called OpenSSH. You will also learn about some of the configuration settings possible with the OpenSSH server application and how to change them on your Ubuntu system.

OpenSSH is a freely available version of the Secure Shell (SSH) protocol family of tools for remotely controlling a computer or transferring files between computers. Traditional tools used to accomplish these functions, such as telnet or rcp, are insecure and transmit the user's password in cleartext when used. OpenSSH provides a server daemon and client tools to facilitate secure, encrypted remote control and file transfer operations, effectively replacing the legacy tools.

The OpenSSH server component, sshd, listens continuously for client connections from any of the client tools. When a connection request occurs, sshd sets up the correct connection depending on the type of client tool connecting. For example, if the remote computer is connecting with the ssh client application, the OpenSSH server sets up a remote control session after authentication. If a remote user connects to an OpenSSH server with scp, the OpenSSH server daemon initiates a secure copy of files between the server and client after authentication. OpenSSH can use many authentication methods, including plain password, public key, and Kerberos tickets.
Installation

Installation of the OpenSSH client and server applications is simple. To install the OpenSSH client applications on your Ubuntu system, use this command at a terminal prompt:

sudo apt-get install openssh-client

To install the OpenSSH server application, and related support files, use this command at a terminal prompt:

sudo apt-get install openssh-server

Configuration

You may configure the default behavior of the OpenSSH server application, sshd, by editing the file /etc/ssh/sshd_config. For information about the configuration directives used in this file, you may view the appropriate manual page with the following command, issued at a terminal prompt:

man sshd_config

There are many directives in the sshd configuration file controlling such things as communications settings and authentication modes. The following are examples of configuration directives that can be changed by editing the /etc/ssh/ssh_config file.
[Tip]  

Prior to editing the configuration file, you should make a copy of the original file and protect it from writing so you will have the original settings as a reference and to reuse as necessary.

Copy the /etc/ssh/sshd_config file and protect it from writing with the following commands, issued at a terminal prompt:

sudo cp /etc/ssh/sshd_config /etc/ssh/sshd_config.original
sudo chmod a-w /etc/ssh/sshd_config.original

The following are examples of configuration directives you may change:

To set your OpenSSH to listen on TCP port 2222 instead of the default TCP port 22, change the Port directive as such:

Port 2222

To have sshd allow public key-based login credentials, simply add or modify the line:

PubkeyAuthentication yes

in the /etc/ssh/sshd_config file, or if already present, ensure the line is not commented out.

To make your OpenSSH server display the contents of the /etc/issue.net file as a pre-login banner, simply add or modify the line:

Banner /etc/issue.net

in the /etc/ssh/sshd_config file.

After making changes to the /etc/ssh/sshd_config file, save the file, and restart the sshd server application to effect the changes using the following command at a terminal prompt:

sudo /etc/init.d/ssh restart

[Warning]  

Many other configuration directives for sshd are available for changing the server application's behavior to fit your needs. Be advised, however, if your only method of access to a server is ssh, and you make a mistake in configuring sshd via the /etc/ssh/sshd_config file, you may find you are locked out of the server upon restarting it, or that the sshd server refuses to start due to an incorrect configuration directive, so be extra careful when editing this file on a remote server.