답변
처음에는 퍼티 명령이 없습니다. 이것들은 쉘 명령입니다.
쉘에서 PHP 스크립트를 실행하려면 PHP-CLI 사용해야합니다PHP에서 명령 줄 스크립팅을 사용할 수도 있습니다. 원하는대로 달라집니다. http://php.net/manual/en/features.commandline.php
감사합니다. 그걸 확인하게 해줘. –
"내 웹 사이트 (다른 서버)로 SSH를 통해 어떻게 연결합니까?"라는 말은 PECL ssh2 라이브러리에서 수행 할 수 있습니다.
참조 : http://pecl.php.net/package/ssh2
연습 (안된) : http://kevin.vanzonneveld.net/techblog/article/make_ssh_connections_with_php/
나는 확실하지 않다 그러나 나는 (만약 내가 잘못 날 수정) 당신이 웹 페이지에 링크 곳을 클릭합니다 생각 (사용자의 컴퓨터에서) 퍼티를 열어 서버에 연결하십시오.
ssh : // 링크를 처리하도록 퍼티를 구성 할 수 있습니다. 이를 수행하는 방법은 here입니다.
이<a href="ssh://[email protected]">Click here to connect</a>
이 만 SSH를 처리하도록 구성된 시스템에서 작동합니다 염두에두고 : 그가 구성되면
은 당신이해야 할 모든이 유사한 링크를하는 것입니다 // 링크 유형
귀하의 질문에 대한 답변입니다.
답장을 보내 주셔서 감사합니다. 나는 그것을 지금 점검 할 것이다. –
이것은 PHP를 통해 putty를 사용하는 방법입니다 (cli에 종속적이지 않음). 암호는 보호되지 않으며 대화 형 ssh 세션이 훨씬 더 복잡하게됩니다. 그러나 HTTPS 및 mcrypt (암호 및/또는 bash 스크립트를 저장할 필요가있는 경우)를 사용하면이 솔루션을 안전한 솔루션으로 만들 수 있습니다.
<?php
// EDIT: added escapeshellcmd() to following vars
$user = escapeshellcmd($_POST['user']); // username
$host = escapeshellcmd($_POST['host']); // domain
$pass = escapeshellcmd($_POST['pass']); // password
// create a string that will be loaded into a bash file for putty
// String can easily be made dynamically.
$bash_sh = <<<EOF #START OF BASH
\#!/bin/bash
echo "BASH ON SSHD SIDE"
for ((i=1; i<=5; i++)) # BASH FOR LOOP
do
echo "echo \$i times in bash" #\$i is BASH not PHP, so have to escape
done
EOF; #END OF BASH
// creates a temp file called 'bash.sh' using the bash script above
file_put_contents("bash.sh", $bash_sh);
// executes putty using the args -ssh, -pw, -t, -m
// -ssh tells putty to use ssh protocol
// -pw tells putty to enter the password automaticaly
// -t tells putty to use a psudo terminal.
// -m tells putty read and execute bash.sh once logged in
exec("putty.exe -ssh ".$user."@".$host." -pw ".$pass." -t -m bash.sh");
// delete bash file since it has been sent
unlink('bash.sh');
?>
또한 escapeshellcmd()를 사용하여 명령 줄 삽입을 방지해야합니다. – JSON
- 1. PHP Seclib close connection SSH
- 2. ruby shoes ssh connection
- 3. php IMAP connection failed
- 4. php adodb MSSQL connection
- 5. php mysql connection timeour 오류
- 6. Heroku postgres connection in PHP
- 7. PHP : 기존 SSH 연결을 통한 SSH
- 8. from : 읽을 수 없습니다 /var/mail/boto.s3.connection
- 9. PHP Orm from model
- 10. Ajax from PHP
- 11. Unix Mail from PHP
- 12. Kerberos login from php
- 13. SHA256withRSA sign from PHP
- 14. COM 객체 from PHP
- 15. open colorbox from php
- 16. 윈도우 - PHP SSH 원격 연결
- 17. Wordpress push post from php
- 18. PHP SQL Select From Where
- 19. jquery data retrieval from php
- 20. Vacuum PostgreSQL DB from PHP
- 21. get_meta_tags() connection refused
- 22. EC2, bottle.py connection
- 23. perforce connection
- 24. linq to sql connection
- 25. mysql connection id (thread_id)
- 26. SSH
- 27. PHP 용 Netbeans의 원격 서버에 ssh 로그인
- 28. Apache PHP 스크립트에서 실행중인 ssh-agent가 필요합니다.
- 29. xampp/php - rsync ssh 공개 패스워드 없음
- 30. java from String [] from
퍼티를 열어야하는 이유는 무엇이라고 생각하십니까? – sberry
링크를 클릭하면 제공된 사용자 이름을 사용하여 서버로 ssh해야합니다. –
그럼 어떻게 하시겠습니까? 대화식이되기를 기대하십니까? – sberry