[第一周]Ubuntu 14.10远程登录服务器--ssh的安装和配置

转载自:http://uknowsec.cn/posts/linux/%E7%AC%AC%E4%B8%80%E5%91%A8-Ubuntu-14-10%E8%BF%9C%E7%A8%8B%E7%99%BB%E5%BD%95%E6%9C%8D%E5%8A%A1%E5%99%A8-ssh%E7%9A%84%E5%AE%89%E8%A3%85%E5%92%8C%E9%85%8D%E7%BD%AE.html)

前言

ssh是一种安全协议,主要用于给远程登录会话数据进行加密,保证数据传输的安全,现在在需怒江Ubuntu 14.04环境下安装和配置ssh。

正文

更新源列表

sudo apt-get update

安装ssh

sudo apt-get install openssh-server

执行命令出现如下情况,按照提示貌似需要安装openshh-client和ssh-import-id

sudo apt-get install openshh-client
sudo apt-get install ssh-import-id

安装完openshh-client和ssh-import-id后还是显示错误

然后得知Ubuntu自带的openssh-clien与所要安装的openssh-server所依赖的版本不同,这里所依赖的版本是

1:6.6p1-2ubuntu2.8

所以要安装降级安装低版本的openssh-clien,来覆盖Ubuntu自带的openssh-clien版本

sudo apt-get install openssh-client=1:6.6p1-2ubuntu1
uknow@uknow-ubuntu:~$ sudo apt-get install openssh-client=1:6.6p1-2ubuntu1
正在读取软件包列表... 完成
正在分析软件包的依赖关系树       
正在读取状态信息... 完成       
下列软件包是自动安装的并且现在不需要了:
  apparmor-easyprof apparmor-easyprof-ubuntu click click-apparmor
  gir1.2-click-0.4 gir1.2-gee-0.8 libclick-0.4-0 libcolord1
  libgnome-desktop-3-7 libgtop2-7 liblttng-ust-ctl2 liblttng-ust0
  libupstart-app-launch2 liburcu1 python3-apparmor python3-apparmor-click
  python3-click python3-libapparmor upstart-app-launch
  upstart-app-launch-tools
Use 'apt-get autoremove' to remove them.
建议安装的软件包:
  libpam-ssh keychain monkeysphere
下列软件包将被【降级】:
  openssh-client
升级了 0 个软件包,新安装了 0 个软件包,降级了 1 个软件包,要卸载 0 个软件包,有 7 个软件包未被升级。
需要下载 566 kB 的软件包。
解压缩后将会空出 54.3 kB 的空间。
您希望继续执行吗? [Y/n] 
获取:1 http://ftp.cuhk.edu.hk/pub/Linux/ubuntu/ trusty/main openssh-client amd64 1:6.6p1-2ubuntu1 [566 kB]
下载 566 kB,耗时 1秒 (419 kB/s)        
dpkg:警告:downgrading openssh-client from 1:6.6p1-8 to 1:6.6p1-2ubuntu1
(正在读取数据库 ... 系统当前共安装有 171295 个文件和目录。)
Preparing to unpack .../openssh-client_1%3a6.6p1-2ubuntu1_amd64.deb ...
Unpacking openssh-client (1:6.6p1-2ubuntu1) over (1:6.6p1-8) ...
Processing triggers for man-db (2.7.0.2-2) ...

可以看到,提示了系统中openssh-client被降级

再安装openssh-server就可以成功了

sudo  apt-get install openssh-server
uknow@uknow-ubuntu:~$ sudo  apt-get install openssh-server
正在读取软件包列表... 完成
正在分析软件包的依赖关系树       
正在读取状态信息... 完成       
下列软件包是自动安装的并且现在不需要了:
  apparmor-easyprof apparmor-easyprof-ubuntu click click-apparmor
  gir1.2-click-0.4 gir1.2-gee-0.8 libclick-0.4-0 libcolord1
  libgnome-desktop-3-7 libgtop2-7 liblttng-ust-ctl2 liblttng-ust0
  libupstart-app-launch2 liburcu1 python3-apparmor python3-apparmor-click
  python3-click python3-libapparmor upstart-app-launch
  upstart-app-launch-tools
Use 'apt-get autoremove' to remove them.
将会安装下列额外的软件包:
  libck-connector0 ncurses-term openssh-client openssh-sftp-server
建议安装的软件包:
  libpam-ssh keychain monkeysphere rssh molly-guard
下列【新】软件包将被安装:
  libck-connector0 ncurses-term openssh-server openssh-sftp-server
下列软件包将被升级:
  openssh-client
升级了 1 个软件包,新安装了 4 个软件包,要卸载 0 个软件包,有 7 个软件包未被升级。
需要下载 1,173 kB 的软件包。
解压缩后会消耗掉 3,344 kB 的额外空间。
您希望继续执行吗? [Y/n] 
获取:1 http://ftp.cuhk.edu.hk/pub/Linux/ubuntu/ trusty/main libck-connector0 amd64 0.4.5-3.1ubuntu2 [10.5 kB]
获取:2 http://ftp.cuhk.edu.hk/pub/Linux/ubuntu/ trusty-security/main openssh-client amd64 1:6.6p1-2ubuntu2.8 [564 kB]
获取:3 http://ftp.cuhk.edu.hk/pub/Linux/ubuntu/ trusty/main ncurses-term all 5.9+20140118-1ubuntu1 [243 kB]
获取:4 http://ftp.cuhk.edu.hk/pub/Linux/ubuntu/ trusty-security/main openssh-sftp-server amd64 1:6.6p1-2ubuntu2.8 [34.2 kB]
获取:5 http://ftp.cuhk.edu.hk/pub/Linux/ubuntu/ trusty-security/main openssh-server amd64 1:6.6p1-2ubuntu2.8 [322 kB]
下载 1,173 kB,耗时 2秒 (470 kB/s)      
正在预设定软件包 ...
Selecting previously unselected package libck-connector0:amd64.
(正在读取数据库 ... 系统当前共安装有 171295 个文件和目录。)
Preparing to unpack .../libck-connector0_0.4.5-3.1ubuntu2_amd64.deb ...
Unpacking libck-connector0:amd64 (0.4.5-3.1ubuntu2) ...
Preparing to unpack .../openssh-client_1%3a6.6p1-2ubuntu2.8_amd64.deb ...
Unpacking openssh-client (1:6.6p1-2ubuntu2.8) over (1:6.6p1-2ubuntu1) ...
Selecting previously unselected package ncurses-term.
Preparing to unpack .../ncurses-term_5.9+20140118-1ubuntu1_all.deb ...
Unpacking ncurses-term (5.9+20140118-1ubuntu1) ...
Selecting previously unselected package openssh-sftp-server.
Preparing to unpack .../openssh-sftp-server_1%3a6.6p1-2ubuntu2.8_amd64.deb ...
Unpacking openssh-sftp-server (1:6.6p1-2ubuntu2.8) ...
Selecting previously unselected package openssh-server.
Preparing to unpack .../openssh-server_1%3a6.6p1-2ubuntu2.8_amd64.deb ...
Unpacking openssh-server (1:6.6p1-2ubuntu2.8) ...
Processing triggers for man-db (2.7.0.2-2) ...
Processing triggers for ufw (0.34~rc-0ubuntu4) ...
Processing triggers for ureadahead (0.100.0-16) ...
ureadahead will be reprofiled on next reboot
正在设置 libck-connector0:amd64 (0.4.5-3.1ubuntu2) ...
正在设置 openssh-client (1:6.6p1-2ubuntu2.8) ...
正在设置 ncurses-term (5.9+20140118-1ubuntu1) ...
正在设置 openssh-sftp-server (1:6.6p1-2ubuntu2.8) ...
正在设置 openssh-server (1:6.6p1-2ubuntu2.8) ...
Creating SSH2 RSA key; this may take some time ...
Creating SSH2 DSA key; this may take some time ...
Creating SSH2 ECDSA key; this may take some time ...
Creating SSH2 ED25519 key; this may take some time ...
ssh start/running, process 7136
Processing triggers for libc-bin (2.19-10ubuntu2) ...
Processing triggers for ufw (0.34~rc-0ubuntu4) ...
Processing triggers for ureadahead (0.100.0-16) ...

ssh服务

sudo ps -e |grep ssh       //查看ssh服务是否启动
sudo service ssh start     //开启ssh服务
sudo service ssh stop       //关闭ssh服务

修改配置文件sshd_config

  • 使用gedit修改配置文件”/etc/ssh/sshd_config”
sudo gedit /etc/ssh/sshd_config
  • 将其中的PermitRootLogin改为
PermitRootLogin yes

利用Xshell连接

  • 查看本机ip
    注意物理机和虚拟机网络方式需要使用桥接模式
ifconfig

  • 使用Xshell登录ubuntu


  • xshell上利用ifconfig

至此,成功的配置好了ssh并成功利用Xshel连接。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值