我正在尝试创建一个java程序,它将在我的macbook上为我设置SSH连接.它提示我输入用户名,然后是IP地址,然后它应该是"ssh username @ ip".
以下是我的代码:
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;
public class SSH {
public static void main(String[] args) throws Exception {
boolean rep = true;
String username = (null);
String IPAdress = (null);
while (rep) {
Scanner scanner = new Scanner(System.in);
System.out.print("Username: ");
username = scanner.next();
System.out.print("\nIP Adress: ");
IPAdress = scanner.next();
System.out.println("\n\nIs this correct?\nUsername: " + username + "\nIP Adress: " + IPAdress + "\nY/N");
char responce = scanner.next().charAt(0);
if (responce == 'Y' || responce == 'y') …Run Code Online (Sandbox Code Playgroud)