ssh_config-0

问题描述:如何在WINDOWS下使用copSSH配置GIT服务器+TortiseGIT客户端 大家好,给大家分享一下一个有趣的事情,很多人还不知道这一点。下面详细解释一下。现在让我们来看看!

windows 中如何用SSH 连接 linux

ssh_config-0的相关图片

近日对GIT进行了研究,发现还真是个好东东,但是在GIT服务器的配置上,在试用了多个SSH服务器之后,始终未能搞定,导致几近崩溃;今把过程展示出来,希望对大家能有帮助。

基本原理:使用copSSH在WINDOWS(XP)上建立SSH服务器;使用生成的“公钥-私钥”对作为身份标识;在服务器上配置SHELL脚本环境;配置客户端,加载私钥。详细过程如下:

安装前准备:

Download copSSH [SourceForge Link] (注:SSH服务器软件)

Download msysgit (注:WINDOWS下的git安装包)

Download TortiseGIT (注:WINDOWS下的git图形化软件,与TortiseSVN是同门)

Download PuTTY Installer (注:生成公钥-私钥对的软件,并可用于SSH客户端的登陆)

Step1 -安装copSSH。

将copSSH(basic edition 2.0.0)安装到路径 c:\SSH。

安装过程中写下SvcCOPSSH的密码,你可能永远不会用到,但写下也无伤大雅。

启动copSSH,选择 开始->所有程序->copSSH->control panel;然后激活一个用户(假定为Administrator,选择Users->Add,下一步,选择一个用户,不要勾选Allow password authenticatin选项,点击forward,OK。

其他关于public keys的事情无需操作,后面还会讲到。

Step2-配置copSSH

选择路径-C:\SSH\etc ,在记事本中打开ssh_config 和sshd_config.(注意:两个文件有一个字母“d”的区别)

ssh_config -删除Port前的#号,设置端口号,这里采用默认端口22。

sshd_config -保证端口号一致。

确定系统防火墙中该端口未关闭。(这一点很重要)

重启系统

Step3-安装Putty

重启之后,继续回来,现在可以安装Putty Installer了。

导航至安装路径,通常为c:\program files\Putty。

打开PuttyGen.exe

选择生成密钥的长度4096

在空白面板处不停地晃动鼠标(用于生成随机种子),直到生成结束。(不要关闭PuttyGen)

来到路径c:\SSH\Home\Administrator\.ssh\ (这个路径在使用copSSH激活用户时会产生,根据激活的用户名,选择相应的路径),创建文件authorized_keys (注意没有后缀名)

打开PuttyGen,复制Public Key(公钥)到文件authorized_keys ,并保存。

在PuttyGen中,将Private Key(私钥)保存为private_key.ppk,保存在同一目录下。-比如,我的保存目录为c:\SSH\Home\Administrator\.ssh\private_key.ppk。

现在目录下应该有两个文件了,authorized_keys  和 private_key.ppk。

为了测试连接,运行putty.exe。

在打开的界面中输入IP 地址(本机可以为localhost)和端口号。

打开左侧的菜单,选择Connection-SSH-Auth,选择你的私钥文件,c:\SSH\Home\<user>\.ssh\private_key.ppk。

点击Open,就会打开终端,让你输入Login Name,输入Administrator(注意大小写)

会看到显示接受你的公钥(Accept Public Key),客户端登陆成功,登陆信息也会缓存起来。

Step 4-安装 msysgit和TortiseGIT。

安装msysgit的过程中一路下一步即可,假定你的路径为C:\msysgit。

安装TortiseGIT,完成之后。

1)在任意路径点右键,选择TortiseGIT-Settings,设置git.exe的路径为c:\msysgit\msysgit\bin,即为msysgit的安装路径。

2)在左侧菜单中选择Network,选择SSH Client为putty中的plink.exe(如我的路径为C:\Program Files\PuTTY\plink.exe)

将几个GIT运行中需要的文件复制到SSH服务器目录,当客户端远程登陆上来以后需要执行这些文件,文件源路径为c:\msysgit\msysgit\Git\libexec\git-core ,要复制的文件包括git.exe, git-receive-pack.exe, git-upload-archive.exe and git-upload-pack.exe,将以上文件复制到C:\SSH\Bin。

Step5-配置用户环境

对于copSSH来说,其默认的$HOME环境为c:\Documents and Settings\<user>,GIT也将会在该目录下寻找authorized_keys 文件。当然这是要避免的事,要将GIT的路径重定向到C:\SSH\Home\<user>\.ssh 。

选择路径C:\SSH\Home\Administrator\,打开.bashrc文件,在# User dependent .bashrc file下面加上这样一段:export HOME=/c/SSH/home/Administrator Shell Options,(注意不要有其他空格出现),然后选择保存。

把该文件复制到用户目录下,如: c:\Documents and Settings\Administrator\。

Step7-使用GIT和Plink。

打开路径C:\SSH\home\Administrator,创建文件夹myapp.git。

在该文件夹上点右键,选择git create repository here,勾选make it bare,服务器文件仓库创建成功。

导航至路径c:\Program Files\PuTTY ,打开pageant.exe,选择add key,将你的私钥(private_key.ppk)加载上。

然后右键选择 git clone,url设为ssh://administrator@127.0.0.1:22/SSH/Home/administrator/myapp.git ,如果clone成功,恭喜大功告成!

注:在执行git clone时可能会报错,如果是关于某个dll文件的错(具体是哪个文件记不清了,遇到的朋友可以根据文件名,在msysigt目录下搜索即可找到),可以将该文件同样复制到C:\SSH\Bin下,然后就可以正常运行了。

ssh连接不成功解决办法的相关图片

ssh连接不成功解决办法

这里的”远程”操控的方法实际上也不是真正的远程.,此操作方法主要是在一个局域网内远程操控电脑 (在一个路由器下)。

操作步骤:

1、百度搜索“SSH Secure Shell Client”下载并安装。

2、打开我们安装好的SSH Secure Shell Client。

3、点击Profiles选择add profiles 并添加profils名称(自定义一个名字)

4、然后点击刚定义好的profiles,出现如下界面,填写远程linux的ip,用户名,密码,port 默认为22;Authentication 选择password,点击connect。

5、出现如下界面,表示连接成功。

6、选择文件夹按钮可以用“资源管理器”的形式查看,传输文件。

7、出现如下界面,左面是指你的桌面,右面是你的远程linux桌面,接下来你就可以尽情操纵你的linux了。

ssh2配置文件详解的相关图片

ssh2配置文件详解

我们使用 ssh 链接 linux 主机时,可能出现“ Host key verification failed.“的提示,ssh连接不成功。

可能的提示信息如下:

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@。

@    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。

23:00:20:83:de:02:95:f1:e3:34:be:57:3f:cf:2c:e7.。

Please contact your system administrator.。

Add correct host key in /home/xahria/.ssh/known_hosts to get rid of this message.。

Offending key in /home/xahria/.ssh/known_hosts:8。

RSA host key for localhost has changed and you have requested strict checking.。

Host key verification failed.。

网上很多的解决方案是:vi ~/.ssh/known_hosts 删除与想要连接的主机相关的行;或者直接删除known_hosts这个文件。 当然这个方案也是可行的,但并非解决问题的根本办法,因为继续使用,今后还会出现这样的情况,还得再删除。

下面简单讲一下这个问题的原理和比较长久的解决方案。

用OpenSSH的人都知ssh会把你每个你访问过计算机的公钥(public key)都记录在~/.ssh/known_hosts。当下次访问相同计算机时,OpenSSH会核对公钥。如果公钥不同,OpenSSH会发出警告,避免你受到DNS Hijack之类的攻击。

SSH对主机的public_key的检查等级是根据StrictHostKeyChecking变量来配置的。默认情况下,StrictHostKeyChecking=ask。简单所下它的三种配置值:

1.StrictHostKeyChecking=no。

#最不安全的级别,当然也没有那么多烦人的提示了,相对安全的内网 测试 时建议使用。如果连接 server 的key在本地不存在,那么就自动添加到文件中(默认是known_hosts),并且给出一个警告。

2.StrictHostKeyChecking=ask  #默认的级别,就是出现刚才的提示了。如果连接和key不匹配,给出提示,并拒绝登录。

3.StrictHostKeyChecking=yes  #最安全的级别,如果连接与key不匹配,就拒绝连接,不会提示详细信息。

对于我来说,在内网的进行的一些测试,为了方便,选择最低的安全级别。在.ssh/config(或者/etc/ssh/ssh_config)中配置:

StrictHostKeyChecking no。

UserKnownHostsFile /dev/null。

(注:这里为了简便,将knownhostfile设为/dev/null,就不保存在known_hosts中了)

参考资料:http://www.symantec.com/connect/articles/ssh-host-key-protection。

ssh连接时这个错误怎么解决的相关图片

ssh连接时这个错误怎么解决

看下配置文件就明白了,主要有访问主机,机密方式,端口,协议版本等。

cat /etc/ssh/ssh_config 。

# $OpenBSD: ssh_config,v 1.23 2007/06/08 04:40:40 pvalchev Exp $。

# This is the ssh client system-wide configuration file. See。

# ssh_config(5) for more information. This file provides defaults for。

# users, and the values can be changed in per-user configuration files。

# or on the command line.。

# Configuration data is parsed as follows:。

# 1. command line options。

# 2. user-specific file。

# 3. system-wide file。

# Any configuration value is only changed the first time it is set.。

# Thus, host-specific definitions should be at the beginning of the。

# configuration file, and defaults at the end.。

# Site-wide defaults for some commonly used options. For a comprehensive。

# list of available options, their meanings and defaults, please see the。

# ssh_config(5) man page.。

Host *

# ForwardAgent no。

# ForwardX11 no。

# If you do not trust your remote host (or its administrator), you。

# should not forward X11 connections to your local X11-display for。

# security reasons: Someone stealing the authentification data on the。

# remote side (the "spoofed" X-server by the remote sshd) can read your。

# keystrokes as you type, just like any other X11 client could do.。

# Set this to "no" here for global effect or in your own ~/.ssh/config。

# file if you want to have the remote X11 authentification data to 。

# expire after two minutes after remote login.。

ForwardX11Trusted yes。

# RhostsRSAAuthentication no。

# RSAAuthentication yes。

# PasswordAuthentication yes。

# HostbasedAuthentication no。

# GSSAPIAuthentication no。

# GSSAPIDelegateCredentials no。

# BatchMode no。

# CheckHostIP yes。

# AddressFamily any。

# ConnectTimeout 0。

# StrictHostKeyChecking ask。

# IdentityFile ~/.ssh/identity。

# IdentityFile ~/.ssh/id_rsa。

# IdentityFile ~/.ssh/id_dsa。

# Port 22

Protocol 2

# Cipher 3des。

# Ciphers aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,arcfour,aes192-cbc,aes256-cbc。

# MACs hmac-md5,hmac-sha1,umac-64@openssh.com,hmac-ripemd160。

# EscapeChar ~。

# Tunnel no

# TunnelDevice any:any。

# PermitLocalCommand no。

# GSSAPIAuthentication no。

# GSSAPIDelegateCredentials no。

# Set this to 'yes' to enable support for the deprecated 'gssapi' authentication。

# mechanism to OpenSSH 3.8p1. The newer 'gssapi-with-mic' mechanism is included。

# in this release. The use of 'gssapi' is deprecated due to the presence of 。

# potential man-in-the-middle attacks, which 'gssapi-with-mic' is not susceptible to.。

# GSSAPIEnableMITMAttack no。

# This enables sending locale enviroment variables LC_* LANG, see ssh_config(5).。

SendEnv LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES 。

SendEnv LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT 。

SendEnv LC_IDENTIFICATION LC_ALL。

前辈们!我不小心删掉了linux中ssh里的ssh_config怎么能弄回来!!!谢谢!

这种问题是由于公钥不一样了,所以无法登录,提示信息是 KEY 验证失败。

解决方法是:

在/root/.ssh/known_hosts 文件里面将原来的公钥信息删除即可。

具体原因分析:SSH 报“Host key verification failed.”。一般来说,出现该错误有这么几种可能:。

.ssh/known_hosts 里面记录的目标主机 key 值不正确。这是最普遍的情况,只要删除对应的主机记录就能恢复正常。

2. .ssh 目录或者 .ssh/known_hosts 对当前用户的权限设置不正确。这种情况比较少,一般正确设置读写权限以后也能恢复正常。

3. /dev/tty 对 other 用户没有放开读写权限。这种情况极为罕见。出现的现象是,只有 root 用户能够使用 ssh client,而所有其他的普通用户都会出现错误。

我今天遇到的就是第三种情况,修改 /dev/tty 的权限后,一切正常。为了避免以后忘记解决方法,记录在这里。

问题2: ssh_exchange_identification: Connection closed by remote host。

-------------------------------------------------------------------------------解决办法:修改/etc/hosts.allow文件,加入 sshd:ALL。

符相关配制说明: vi /etc/ssh/ssh_config。

-------------------------------------------------。

下面逐行说明上面的选项设置:

Host * :选项“Host”只对能够匹配后面字串的计算机有效。“*”表示所有的计算机。

ForwardAgent no :“ForwardAgent”设置连接是否经过验证代理(如果存在)转发给远程计算机。

ForwardX11 no :“ForwardX11”设置X11连接是否被自动重定向到安全的通道和显示集(DISPLAY set)。

RhostsAuthentication no :“RhostsAuthentication”设置是否使用基于rhosts的安全验证。

RhostsRSAAuthentication no :“RhostsRSAAuthentication”设置是否使用用RSA算法的基于rhosts的安全验证。

RSAAuthentication yes :RSAAuthentication”设置是否使用RSA算法进行安全验证。

PasswordAuthentication yes :“PasswordAuthentication”设置是否使用口令验证。

FallBackToRsh no:“FallBackToRsh”设置如果用ssh连接出现错误是否自动使用rsh。

UseRsh no :“UseRsh”设置是否在这台计算机上使用“rlogin/rsh”。

BatchMode no :“BatchMode”如果设为“yes”,passphrase/password(交互式输入口令)的提示将被禁止。当不能交互式输入口令的时候,这个选项对脚本文件和批处理任务十分有用。

CheckHostIP yes :“CheckHostIP”设置ssh是否查看连接到服务器的主机的IP地址以防止DNS欺骗。建议设置为“yes”。

StrictHostKeyChecking no :“StrictHostKeyChecking”如果设置成“yes”,ssh就不会自动把计算机的密匙加入“$HOME/.ssh/known_hosts”文件,并且一旦计算机的密匙发生了变化,就拒绝连接。

IdentityFile ~/.ssh/identity :“IdentityFile”设置从哪个文件读取用户的RSA安全验证标识。

Port 22 :“Port”设置连接到远程主机的端口。

原文地址:http://www.qianchusai.com/ssh_config-0.html

json字符串取key,json字符串怎么取值

json字符串取key,json字符串怎么取值

海城牛庄大庙,海城牛庄大庙什幺时候开

海城牛庄大庙,海城牛庄大庙什幺时候开

ineluctable,ineluctable趣词词典

ineluctable,ineluctable趣词词典

sailing-80

sailing-80

ferris-20

ferris-20

润羽露西娅手办,润羽露西娅站队了吗

润羽露西娅手办,润羽露西娅站队了吗

inflat-20

inflat-20

6538-40,65384098

6538-40,65384098

HP2775打印机如何关机,惠普打印机2722怎么关机

HP2775打印机如何关机,惠普打印机2722怎么关机

adguardhome最快ip模式,adguard home如何设置

adguardhome最快ip模式,adguard home如何设置