在linux上通过ssh直接登录到windows系统上,不用密码

简介: 实验目的:在linux上通过ssh直接登录到windows系统上,不用密码 实验环境:在windows上安装cygwin,在linux 上通过ssh 连接到windows           Windows ip  :10.

实验目的:在linux上通过ssh直接登录到windows系统上,不用密码

实验环境:在windows上安装cygwin,在linux 上通过ssh 连接到windows

          Windows ip  10.1.165.1   linux ip 10.1.151.111

配置前,由linux登录到windows需要密码

[yang@rac1 python]$ ssh -laaaa 10.1.165.1

aaaa@10.1.165.1's password:

Last login: Sun Jul 17 20:16:05 2011 from 127.0.0.1

aaaa@dfvkr-PC ~

$ dir

aaaa@dfvkr-PC ~

$ pwd

/home/aaaa

步骤:

1 linux上通过ssh-keygen –t rsa 产生密钥

[yang@rac1 ~]$ ssh-keygen -t rsa

Generating public/private rsa key pair.

Enter file in which to save the key (/home/yang/.ssh/id_rsa):

Enter passphrase (empty for no passphrase):

Enter same passphrase again:

Your identification has been saved in /home/yang/.ssh/id_rsa.

Your public key has been saved in /home/yang/.ssh/id_rsa.pub.

The key fingerprint is:

58:d9:4d:ad:04:08:ae:f7:5d:15:fd:36:58:b3:79:a2 yang@rac1

home/yang目录下产生.ssh,修改其属性

[yang@rac1 ~]$ chmod 755 .ssh

进入该文件夹,查看生成的文件

[yang@rac1 .ssh]$ ls

id_rsa  id_rsa.pub  known_hosts

其中id_rsa 为私钥,id_rsa.pub 为公钥。我们需要将公钥拷贝到windows系统中cygwin显示的家目录,我的是/home/aaaa ,在此文件夹下建立 .ssh文件夹。(一下是在windows系统下的操作)

aaaa@dfvkr-PC ~

$ mkdir .ssh

aaaa@dfvkr-PC ~

$ ls -al

total 26

drwxr-xr-x+ 1 aaaa None    0 Jul 18 11:27 .

drwxrwxrwt+ 1 aaaa root    0 Jul 17 19:52 ..

-rw-------  1 aaaa None  309 Jul 18 10:24 .bash_history

-rwxr-xr-x  1 aaaa None 1103 Jul 17 17:28 .bash_profile

-rwxr-xr-x  1 aaaa None 5663 Jul 17 17:28 .bashrc

-rwxr-xr-x  1 aaaa None 1461 Jul 17 17:28 .inputrc

-rwxr-xr-x  1 aaaa None  792 Jul 17 17:28 .profile

drwxr-xr-x+ 1 aaaa None    0 Jul 18 11:27 .ssh

-rw-r--r--  1 aaaa None  391 Jul 18 11:17 d:

然后拷贝linux上生成的公钥到.ssh目录下,并命名为authorized_keys

aaaa@dfvkr-PC ~

$ cd .ssh

aaaa@dfvkr-PC ~/.ssh

$ ls

authorized_keys

再次由linux登录到windows

[yang@rac1 python]$ ssh -laaaa 10.1.165.1

Last login: Mon Jul 18 11:28:20 2011 from 10.1.151.111

 

aaaa@dfvkr-PC ~

$ pwd

/home/aaaa

aaaa@dfvkr-PC ~

$ cd /

aaaa@dfvkr-PC /

$ ls

Cygwin.bat  Cygwin.ico  bin  cygdrive  dev  etc  home  lib  proc  tmp  usr  var

aaaa@dfvkr-PC /

目录
相关文章
|
6天前
|
Ubuntu 安全 Linux
《Linux 简易速速上手小册》第1章: Linux 系统基础(2024 最新版)
《Linux 简易速速上手小册》第1章: Linux 系统基础(2024 最新版)
40 1
|
14天前
|
资源调度 JavaScript 搜索推荐
Linux系统之部署envlinks极简个人导航页
【4月更文挑战第11天】Linux系统之部署envlinks极简个人导航页
53 2
|
16天前
|
缓存 Linux 测试技术
安装【银河麒麟V10】linux系统--并挂载镜像
安装【银河麒麟V10】linux系统--并挂载镜像
83 0
|
14天前
|
存储 算法 Linux
【实战项目】网络编程:在Linux环境下基于opencv和socket的人脸识别系统--C++实现
【实战项目】网络编程:在Linux环境下基于opencv和socket的人脸识别系统--C++实现
38 6
|
1天前
|
Ubuntu Linux
Linux(Ubuntu)系统临时IP以及静态IP配置(关闭、启动网卡等操作)
请注意,以上步骤是在临时基础上进行配置的。如果要永久保存静态IP地址,通常还需要修改 `/etc/network/interfaces`文件,以便在系统重启后保持配置。同时,确保备份相关配置文件以防止出现问题。
9 1
|
1天前
|
Linux 数据安全/隐私保护
Linux系统忘记密码的三种解决办法
这篇博客介绍了三种在Linux忘记密码时重置登录密码的方法:1) 使用恢复模式,通过控制台界面以管理员权限更改密码;2) 利用Linux Live CD/USB启动,挂载硬盘分区并使用终端更改密码;3) 进入单用户模式,自动以管理员身份登录后重置密码。每个方法都提供了详细步骤,提醒用户在操作前备份重要数据。
|
2天前
|
JSON Unix Linux
Linux系统之jq工具的基本使用
Linux系统之jq工具的基本使用
26 1
|
2天前
|
数据采集 监控 安全
linux系统被×××后处理经历
linux系统被×××后处理经历
|
2天前
|
监控 安全 Linux
Linux系统之安装ServerBee服务器监控工具
【4月更文挑战第22天】Linux系统之安装ServerBee服务器监控工具
40 2
|
2天前
|
缓存 Linux
linux系统缓存机制
linux系统缓存机制