SSH Access
SSH into your Freestyle VMs.
SSH Format
ssh vm-id@vm-ssh.freestyle.sh
ssh vm-id:access-token@vm-ssh.freestyle.sh
ssh vm-id+user:access-token@vm-ssh.freestyle.shSSH as Root
To SSH into a VM as root, create an identity with permission to access the VM, then create an access token for that identity:
import { freestyle } from "freestyle-sandboxes";
const { vmId } = await freestyle.vms.create();
const { identity } = await freestyle.identities.create();
await identity.permissions.vms.create({
vmId: vmId,
});
const { token } = await identity.createToken();
console.log(`ssh ${vmId}:${token}@vm-ssh.freestyle.sh`);If you omit the token from the URL, you will be prompted for it as a password:
ssh {vm-id}@vm-ssh.freestyle.sh
# You'll be prompted: Enter your access token as the passwordSSH as a Specific User
Create an identity with permission to access the VM as a specific Linux user:
const { vmId } = await freestyle.vms.create({
users: [
{ name: "developer" },
{ name: "admin" },
],
});
const { identity } = await freestyle.identities.create();
await identity.permissions.vms.create({
vmId: vmId,
allowedUsers: ["developer"],
});
const { token } = await identity.createToken();
console.log(`ssh ${vmId}+developer:${token}@vm-ssh.freestyle.sh`);Multiple Developers
Create separate identities for each developer with their own permissions:
const { vmId } = await freestyle.vms.create({
users: [
{
name: "alice",
gecos: "Alice Smith",
groups: ["sudo", "docker"],
},
{
name: "bob",
gecos: "Bob Jones",
groups: ["sudo", "docker"],
},
],
});
// Create separate identities for each developer
const { identity: aliceIdentity } = await freestyle.identities.create();
await aliceIdentity.permissions.vms.create({
vmId: vmId,
allowedUsers: ["alice"],
});
const { identity: bobIdentity } = await freestyle.identities.create();
await bobIdentity.permissions.vms.create({
vmId: vmId,
allowedUsers: ["bob"],
});
const { token: aliceToken } = await aliceIdentity.createToken();
const { token: bobToken } = await bobIdentity.createToken();
console.log(`Alice: ssh ${vmId}+alice:${aliceToken}@vm-ssh.freestyle.sh`);
console.log(`Bob: ssh ${vmId}+bob:${bobToken}@vm-ssh.freestyle.sh`);Related
- Users and Groups - Create Linux users and groups in your VMs