ssh的基本使用


一、基本使用:
1.连接方式:
ssh IP 如ssh 172.16.28.49 默认以root登录。
或  ssh user@172.16.28.49 选择其它用户

2.显示远程窗口:
ssh -X ...
可以显示远程机器的图形界面,如打开资源管理器等,在命令行下输入"nautilus .",远程主机上的窗口便会显示在本机屏幕上。

3.远程数据传递:
在远程机程机器上可以使用scp进行文件copy

scp -rf [user@]host1:file_path  [user@]host2:file_path2
scp -rf user1@172.16.28.11:/tmp/*.tar user2@172.16.28.12:/tmp

二、使用过程中遇到的问题:
1.错误1:
ssh: connect to host 172.16.28.49 port 22: Connection refused
分析:
远程连接的机器,没有开启ssh
在远程机器上开启ssh  /etc/init.d/sshd start

2.错误2:
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that the RSA host key has just been changed.
The fingerprint for the RSA key sent by the remote host is
1b:19:f3:a5:45:6f:73:74:39:c2:b0:a2:98:1c:87:46.
Please contact your system administrator.
Add correct host key in /root/.ssh/known_hosts to get rid of this message.
Offending key in /root/.ssh/known_hosts:5
RSA host key for 172.16.28.49 has changed and you have requested strict checking.
Host key verification failed.
root@cspark-desktop:/media/ubuntu8.04/opt/cocreatespace/cairo/cairo-1.6.0# rm ~/.ssh/known_hosts
root@cspark-desktop:/media/ubuntu8.04/opt/cocreatespace/cairo/cairo-1.6.0# ssh root@172.16.28.49
The authenticity of host '172.16.28.49 (172.16.28.49)' can't be established.
RSA key fingerprint is 1b:19:f3:a5:45:6f:73:74:39:c2:b0:a2:98:1c:87:46.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '172.16.28.49' (RSA) to the list of known hosts.
....
分析:
在使用ssh连接时,每一次连接,会在 ~/.ssh/known_hosts 文件中记录一些远程主机的信息,如对方的密码改变等,一旦主机的信息与记录文件不符,便会出现如上错误
直接方式: rm ~/.ssh/known_hosts

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值