Search in sources :

Example 1 with SshPublicKey

use of com.microsoft.azure.management.compute.SshPublicKey in project azure-sdk-for-java by Azure.

the class VirtualMachineScaleSetImpl method withSsh.

@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;
}
Also used : SshPublicKey(com.microsoft.azure.management.compute.SshPublicKey) SshConfiguration(com.microsoft.azure.management.compute.SshConfiguration) VirtualMachineScaleSetOSProfile(com.microsoft.azure.management.compute.VirtualMachineScaleSetOSProfile)

Example 2 with SshPublicKey

use of com.microsoft.azure.management.compute.SshPublicKey in project azure-sdk-for-java by Azure.

the class VirtualMachineImpl method withSsh.

// Virtual machine optional fluent methods
//
@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;
}
Also used : OSProfile(com.microsoft.azure.management.compute.OSProfile) SshPublicKey(com.microsoft.azure.management.compute.SshPublicKey) SshConfiguration(com.microsoft.azure.management.compute.SshConfiguration)

Aggregations

SshConfiguration (com.microsoft.azure.management.compute.SshConfiguration)2 SshPublicKey (com.microsoft.azure.management.compute.SshPublicKey)2 OSProfile (com.microsoft.azure.management.compute.OSProfile)1 VirtualMachineScaleSetOSProfile (com.microsoft.azure.management.compute.VirtualMachineScaleSetOSProfile)1