first commit
Some checks failed
Vulhub Format Check and Lint / format-check (push) Has been cancelled
Vulhub Format Check and Lint / markdown-check (push) Has been cancelled
Vulhub Docker Image CI / longtime-images-test (push) Has been cancelled
Vulhub Docker Image CI / images-test (push) Has been cancelled
Some checks failed
Vulhub Format Check and Lint / format-check (push) Has been cancelled
Vulhub Format Check and Lint / markdown-check (push) Has been cancelled
Vulhub Docker Image CI / longtime-images-test (push) Has been cancelled
Vulhub Docker Image CI / images-test (push) Has been cancelled
This commit is contained in:
49
base/erlang/with-ssh/27.3.2/start_ssh.escript
Normal file
49
base/erlang/with-ssh/27.3.2/start_ssh.escript
Normal file
@@ -0,0 +1,49 @@
|
||||
#!/usr/bin/env escript
|
||||
%%! -sname ssh_runner
|
||||
|
||||
main(_) ->
|
||||
application:start(asn1),
|
||||
application:start(crypto),
|
||||
application:start(public_key),
|
||||
application:start(ssh),
|
||||
|
||||
io:format("Starting SSH daemon with logging...~n"),
|
||||
|
||||
case ssh:daemon(2222, [
|
||||
{system_dir, "/etc/ssh"},
|
||||
|
||||
{user_dir_fun, fun(User) ->
|
||||
Dir = filename:join("/home", User),
|
||||
io:format("Resolving user_dir for ~p: ~s/.ssh~n", [User, Dir]),
|
||||
filename:join(Dir, ".ssh")
|
||||
end},
|
||||
|
||||
{connectfun, fun(User, PeerAddr, Method) ->
|
||||
io:format("Auth success for user: ~p from ~p via ~p~n",
|
||||
[User, PeerAddr, Method]),
|
||||
true
|
||||
end},
|
||||
|
||||
{failfun, fun(User, PeerAddr, Reason) ->
|
||||
io:format("Auth failed for user: ~p from ~p, reason: ~p~n",
|
||||
[User, PeerAddr, Reason]),
|
||||
true
|
||||
end},
|
||||
|
||||
{auth_methods, "publickey,password"},
|
||||
|
||||
{user_passwords, [{"root", "vulhub"}]},
|
||||
{idle_time, infinity},
|
||||
{max_channels, 10},
|
||||
{max_sessions, 10},
|
||||
{parallel_login, true}
|
||||
]) of
|
||||
{ok, _Pid} ->
|
||||
io:format("SSH daemon running on port 2222. Press Ctrl+C to exit.~n");
|
||||
{error, Reason} ->
|
||||
io:format("Failed to start SSH daemon: ~p~n", [Reason])
|
||||
end,
|
||||
|
||||
receive
|
||||
stop -> ok
|
||||
end.
|
Reference in New Issue
Block a user