mina-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Amit Kumar (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (SSHD-772) After login using SSHServer program ...It displays "/bin/sh: 0: can't access tty; job control turned off". How to solve this problem?
Date Fri, 15 Sep 2017 07:54:00 GMT

    [ https://issues.apache.org/jira/browse/SSHD-772?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16167486#comment-16167486
] 

Amit Kumar commented on SSHD-772:
---------------------------------

I am new to  sshd, this is the simple code I have written to start ssh server, when I ssh
using terminal "ssh -p2222 amit@<ip address>", It shows me 'bin/sh: 0: can't access
tty; job control turned off'. 

Actually I want to emulate the exact terminal provided by ssh command by using sshd, any reference
you can provide for this purpose is really helpful.

{code:java}
package sshtest;
import java.io.File;
import java.io.IOException;
import java.security.NoSuchAlgorithmException;

import org.apache.sshd.server.SshServer;
import org.apache.sshd.server.auth.password.PasswordAuthenticator;
import org.apache.sshd.server.keyprovider.AbstractGeneratorHostKeyProvider;
import org.apache.sshd.server.keyprovider.SimpleGeneratorHostKeyProvider;
import org.apache.sshd.server.scp.ScpCommandFactory;
import org.apache.sshd.server.session.ServerSession;
import org.apache.sshd.server.shell.ProcessShellFactory;
public class Ssh_Test {
	
	public static void main(String v[]) throws NoSuchAlgorithmException, InterruptedException{
		SshServer sshd = SshServer.setUpDefaultServer();
		sshd.setPort(2222);
		ProcessShellFactory psf=new ProcessShellFactory(new String[] { "/bin/sh", "-i","-l" });
              
		sshd.setShellFactory(psf);		
	    sshd.setCommandFactory(new ScpCommandFactory());
	    sshd.setPasswordAuthenticator(new PasswordAuthenticator() {

			public boolean authenticate(String arg0, String arg1,
					ServerSession arg2) {
				
				return "amit".equals(arg0) && "1".equals(arg1);
			}
                
            });
	    AbstractGeneratorHostKeyProvider kp =
	    		new SimpleGeneratorHostKeyProvider(new File("/home/amit/server.key")); 
	    kp.loadKeys();
	    sshd.setKeyPairProvider(kp);	    
	    System.out.println(kp);
	    try {
	    	System.out.println("start");
			sshd.start();			
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	    Thread.sleep(Long.MAX_VALUE);	    
	}
}
{code}


> After login using SSHServer program ...It displays "/bin/sh: 0: can't access tty; job
control turned off". How to solve this problem?
> -------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: SSHD-772
>                 URL: https://issues.apache.org/jira/browse/SSHD-772
>             Project: MINA SSHD
>          Issue Type: Question
>    Affects Versions: 1.6.0
>         Environment: Ubuntu 16.04 LTS
>            Reporter: Amit Kumar
>
> After login using SSHServer program ...It displays "/bin/sh: 0: can't access tty; job
control turned off". How to solve this problem



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Mime
View raw message