ssh在一台机器上运行,但不在另一台机器上运行

时间:2015-07-15 20:08:42

标签: ssh

我在两台不同的机器上运行一个简单的命令:

ssh -vvvT git@github.com

在一台机器上,这是有效的。在另一台机器上,ssh失败并显示以下消息:

debug1: Server accepts key: pkalg ssh-rsa blen 535
debug2: input_userauth_pk_ok: fp bd:5a:d9:2b:d0:36:1c:f1:dc:f8:83:05:17:b9:04:e0
debug3: sign_and_send_pubkey: RSA bd:5a:d9:2b:d0:36:1c:f1:dc:f8:83:05:17:b9:04:e0
debug1: key_parse_private2: missing begin marker
debug1: key_parse_private_pem: PEM_read_PrivateKey failed
debug1: read PEM private key done: type <unknown>
debug1: read_passphrase: can't open /dev/tty: No such device or address
debug2: no passphrase given, try next key
debug2: we did not send a packet, disable method
debug1: No more authentication methods to try.
Permission denied (publickey).

我在两台机器上使用相同的私钥。私钥具有开始标记(即----- BEGIN RSA私钥-----)。私钥是在没有密码的情况下生成的。 .ssh目录的权限在两台机器上都是相同的(700)。两台计算机上的私钥文件的权限相同(600)。这是我的.ssh / config的内容:

Host github.com
    StrictHostKeyChecking no
    IdentityFile ~/keyfile

我完全混淆了为什么输出显示“缺少开始标记”,为什么它试图读取密码,当然为什么它根本就失败了。有什么我应该尝试帮助诊断这个问题吗?

1 个答案:

答案 0 :(得分:1)

密钥文件上没有标记表明它有密码短语。当ssh从文件中读取密钥时,它首先尝试在没有密码的情况下解释它们的文件内容。如果它无法理解文件的内容,它会要求输入密码并再次尝试读取该文件。你可以为ssh提供一个完整的无意义文件,它会在放弃之前要求输入密码:

<?xml version="1.0" encoding="UTF-8"?>
<project
    xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.rizze.services</groupId>
    <artifactId>xxx</artifactId>
    <packaging>jar</packaging>   
    <version>3.4.2</version>
    <name>wsbase</name>    

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <jersey.version>2.17</jersey.version>

    </properties>

    <pluginRepositories>
        <pluginRepository>
            <id>sonatype-snapshot</id>
            <url>https://oss.sonatype.org/content/repositories/snapshots/</url>
            <releases>
                <enabled>true</enabled>
            </releases>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </pluginRepository>
    </pluginRepositories>


    <dependencies>


       <dependency>
            <groupId>org.glassfish.jersey.containers</groupId>
            <artifactId>jersey-container-servlet-core</artifactId>
            <version>${jersey.version}</version>
        </dependency>

        <dependency>
            <groupId>org.glassfish.jersey.core</groupId>
            <artifactId>jersey-server</artifactId>
            <version>${jersey.version}</version>
        </dependency>
        <dependency>
            <groupId>org.glassfish.jersey.media</groupId>
            <artifactId>jersey-media-multipart</artifactId>
            <version>${jersey.version}</version>
        </dependency>   

       <dependency>
          <groupId>javax.servlet</groupId>
          <artifactId>javax.servlet-api</artifactId>
          <version>3.0.1</version>
         <scope>provided</scope>
      </dependency>

       <dependency>
            <groupId>io.swagger</groupId>
            <artifactId>swagger-core</artifactId>
            <scope>compile</scope>
            <version>1.5.0</version>
            <exclusions>
                <exclusion>
                    <groupId>javax.ws.rs</groupId>
                    <artifactId>jsr311-api</artifactId>
                </exclusion>

          <!-- <exclusion>
                    <groupId>com.fasterxml.jackson.core</groupId>
                    <artifactId>jackson-core</artifactId>
                </exclusion>

                 <exclusion>
                    <groupId>com.fasterxml.jackson.core</groupId>
                    <artifactId>jackson-annotations</artifactId>
                </exclusion> -->      
            </exclusions>
        </dependency>



        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
            <scope>test</scope>
        </dependency>



        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>jcl-over-slf4j</artifactId>
            <version>1.7.5</version>

        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>jul-to-slf4j</artifactId>
            <version>1.7.5</version>

        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <version>1.7.5</version>     
        </dependency>
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-core</artifactId>
            <version>2.3</version>
        </dependency>


        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-web</artifactId>
            <version>2.0-rc2</version>
            <scope>runtime</scope>
        </dependency>
    </dependencies>
    <build>

        <finalName>xxx</finalName>
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>properties-maven-plugin</artifactId>
                <version>1.0-alpha-2</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>set-system-properties</goal>
                        </goals>
                        <configuration>
                            <properties>
                                <property>
                                    <name>log4j.configuration</name>
                                    <value>file:${basedir}/src/main/resources/logs-${env.name}.properties</value>
                                </property>

                            </properties>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
             <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.3</version>
            <configuration>
               <source>1.8</source>
               <target>1.8</target>
               <showDeprecation>true</showDeprecation>
               <showWarnings>true</showWarnings>              
               <fork>true</fork>
            </configuration>
         </plugin>
            <plugin>
                <artifactId>maven-resources-plugin</artifactId>
                <version>2.6</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-eclipse-plugin</artifactId>
                <version>2.6</version>
                <configuration>
                    <wtpversion>2.0</wtpversion>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.8</version>
                <configuration>
                    <systemProperties>
                        <log4j.debug>true</log4j.debug>
                        <parallel>methods</parallel>
                        <threadCount>10</threadCount>
                    </systemProperties>
                    <includes>
                        <include>**/*.java</include>
                    </includes>
                    <!-- skip>true</skip> -->
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>cobertura-maven-plugin</artifactId>
                <version>2.6</version>
                <configuration>
                    <aggregate>true</aggregate>
                    <argLine>-XX:-UseSplitVerifier</argLine>
                    <formats>
                        <format>html</format>
                        <format>xml</format>
                    </formats>
                </configuration>
                <executions>
                    <execution>
                        <phase>site</phase>
                        <goals>
                            <goal>cobertura</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>


         <plugin>
                <groupId>com.github.kongchen</groupId>
                <artifactId>swagger-maven-plugin</artifactId>
                <version>3.1.0</version>
                <configuration>
                    <apiSources>
                      <apiSource>
                            <springmvc>false</springmvc>
                            <locations>com.rizze.services.ressources,</locations>
                            <schemes>http,https</schemes>
                            <host>int.skyos.io</host>
                            <basePath>/api</basePath>
                            <info>
                                <title>${project.artifactId}</title>
                                <version>${project.version}</version> 
                            </info>
                            <templatePath>${basedir}/src/test/resources/swagger/templates/template_rizze</templatePath>
                            <outputPath>${basedir}/target/docs/html/home.jsp</outputPath>
                            <!--  swaggerDirectory>generated/swagger-ui</swaggerDirectory>-->
                        </apiSource>
                    </apiSources>
                </configuration>
                <executions>
                    <execution>
                        <phase>compile</phase>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>






           <plugin>
                <artifactId>maven-jar-plugin</artifactId>
                <version>2.6</version>
                <configuration>
                    <packagingExcludes>
                        WEB-INF/lib/joda-time-2.5.jar,
                        WEB-INF/lib/log4j-1.2.16.jar,
                        WEB-INF/lib/jcommander-1.30.jar
                        ,WEB-INF/lib/joda-time-2.2.jar
                        ,WEB-INF/lib/guava-11.0.1.jar
                        ,WEB-INF/lib/jsonschema2pojo-0.4.0-javadoc.jar
                        ,WEB-INF/lib/jsonschema2pojo-cli-0.3.7.jar
                        ,WEB-INF/lib/jsonschema2pojo-cli-0.4.0-sources.jar
                        ,WEB-INF/lib/jsonschema2pojo-cli-0.4.0.jar
                        ,WEB-INF/lib/jsonschema2pojo-core-0.3.7.jar
                        ,WEB-INF/lib/jsonschema2pojo-core-0.4.0-sources.jar
                        ,WEB-INF/lib/jsonschema2pojo-core-0.4.0.jar
                        ,WEB-INF/lib/jsonschema2pojo-maven-plugin-0.3.7.jar
                        ,WEB-INF/lib/scala-compiler-2.10.0.jar
                        ,WEB-INF/lib/scala-library-2.10.0.jar
                        ,WEB-INF/lib/scala-reflect-2.10.0.jar
                        ,WEB-INF/lib/scalap-2.10.0.jar

                    </packagingExcludes>

                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

换句话说,如果ssh提示您输入密码,并且您确信该文件不应该有密码,那么该文件肯定存在其他问题。例如,它可能会被截断或损坏。