// Set up SSH public key String fullStorePath = " ~/.ssh/authorized_keys"; String sshKeyData = "you-ssh-key-data"; SshPublicKey sshPublicKey = new SshPublicKey(); sshPublicKey.setPath(fullStorePath); sshPublicKey.setKeyData(sshKeyData); // SShConfiguration ArrayList<SshPublicKey> keyList = new ArrayList<SshPublicKey>(); keyList.add(sshPublicKey); SshConfiguration sshConfig = new SshConfiguration(); sshconfig.setPublicKeys(keyList); // Linux Configuration Bool shouldDisablePasswordAuthentication = False; LinuxConfiguration linuxConfig = new LinuxConfiguration(); linuxConfig.setSsh(sshConfig); linuxConfig.setDisablePasswordAuthentication(shouldDisablePasswordAuthentication); // set your OSProfile now request.getOsProfile().setLinuxConfiguration(linuxConfig); // you code goes here
@Override public VirtualMachineImpl withSsh(String publicKeyData) { OSProfile osProfile = this.inner().osProfile(); if (osProfile.linuxConfiguration().ssh() == null) { SshConfiguration sshConfiguration = new SshConfiguration(); sshConfiguration.withPublicKeys(new ArrayList<SshPublicKey>()); osProfile.linuxConfiguration().withSsh(sshConfiguration); } SshPublicKey sshPublicKey = new SshPublicKey(); sshPublicKey.withKeyData(publicKeyData); sshPublicKey.withPath("/home/" + osProfile.adminUsername() + "/.ssh/authorized_keys"); osProfile.linuxConfiguration().ssh().publicKeys().add(sshPublicKey); return this; }
@Override public VirtualMachineImpl withSsh(String publicKeyData) { OSProfile osProfile = this.inner().osProfile(); if (osProfile.linuxConfiguration().ssh() == null) { SshConfiguration sshConfiguration = new SshConfiguration(); sshConfiguration.withPublicKeys(new ArrayList<SshPublicKey>()); osProfile.linuxConfiguration().withSsh(sshConfiguration); } SshPublicKey sshPublicKey = new SshPublicKey(); sshPublicKey.withKeyData(publicKeyData); sshPublicKey.withPath("/home/" + osProfile.adminUsername() + "/.ssh/authorized_keys"); osProfile.linuxConfiguration().ssh().publicKeys().add(sshPublicKey); return this; }
@Override public VirtualMachineScaleSetImpl withSsh(String publicKeyData) { VirtualMachineScaleSetOSProfile osProfile = this.inner() .virtualMachineProfile() .osProfile(); if (osProfile.linuxConfiguration().ssh() == null) { SshConfiguration sshConfiguration = new SshConfiguration(); sshConfiguration.withPublicKeys(new ArrayList<SshPublicKey>()); osProfile.linuxConfiguration().withSsh(sshConfiguration); } SshPublicKey sshPublicKey = new SshPublicKey(); sshPublicKey.withKeyData(publicKeyData); sshPublicKey.withPath("/home/" + osProfile.adminUsername() + "/.ssh/authorized_keys"); osProfile.linuxConfiguration().ssh().publicKeys().add(sshPublicKey); return this; }
@Override public VirtualMachineScaleSetImpl withSsh(String publicKeyData) { VirtualMachineScaleSetOSProfile osProfile = this.inner() .virtualMachineProfile() .osProfile(); if (osProfile.linuxConfiguration().ssh() == null) { SshConfiguration sshConfiguration = new SshConfiguration(); sshConfiguration.withPublicKeys(new ArrayList<SshPublicKey>()); osProfile.linuxConfiguration().withSsh(sshConfiguration); } SshPublicKey sshPublicKey = new SshPublicKey(); sshPublicKey.withKeyData(publicKeyData); sshPublicKey.withPath("/home/" + osProfile.adminUsername() + "/.ssh/authorized_keys"); osProfile.linuxConfiguration().ssh().publicKeys().add(sshPublicKey); return this; }