0

I got disconnected while applying Firewall rules via SSH. So, I can not SSH to my virtual server. As I have access to frontend, port 80, port 443 are open, PHP is running, best way to edit the /etc/ssh/sshd_config file's port. As I have the username/password for the root user, I saw the StackOver other questions. I am not great about PHP coding. I guess, this snippet can connect :

<?php
$ftp_server = "127.0.0.1"; 
$ftp_port = "443"; 
$ftp_user_name = "username";
$ftp_user_pass = "password";
$conn_id = ftp_ssl_connect($ftp_server, $ftp_port, "30");
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
ftp_pasv($conn_id, true);
echo ftp_pwd($conn_id); 
echo "hello";
ftp_close($conn_id);
?>

I need help in modification to delete & upload or overwrite the /etc/ssh/sshd_config file. Thanks in advance.

1 Answers1

0

FTPS (FTP over TLS/SSL) is not SFTP (over SSH).

You need to use PHP SSH2 functions, not FTP functions.

See for example How to SFTP with PHP?

You can also use phpseclib.

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992